What a great post. The more I look, the worse it gets, but not in a normal, “there was initially too much to read it all” kind of way. Someone needs to debug their onEnable method. Like, real bad.
To be like, really pedantic, C#'s foreach will perform an implicit typecast in some scenarios, which can cause the enumeration to throw an InvalidCastException when it hits an item that can't be cast to the specified type (in this case, ShadowCaster2D).
You don't have to write your own implementation of IEnumerable for that. The variable could simply be set from a method that return an IEnumerable due to using yield return. That method could do anything.
I suspect there is some Unity specific context here, even though that wasn't mentioned anywhere. Otherwise I don't know how you can be so sure.
148
u/azarbi Jan 14 '23
Reminds me of when I tried to read from a file in Java :
28
u/CrazySD93 Jan 15 '23
Warning: your catch is too broad
31
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 14 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
11
u/No-Witness2349 Jan 15 '23
What a great post. The more I look, the worse it gets, but not in a normal, “there was initially too much to read it all” kind of way. Someone needs to debug their onEnable method. Like, real bad.
4
u/aridankdev Jan 15 '23
Some errors are not worth fixing lol
2
u/throwawayy0451 Jan 15 '23
what rust could look like with all that Result<T> shit
2
u/nminaya Jan 15 '23
If setting a boolean to true may throw an exception, I would've done the same xd
1
u/ALittlePatate Jan 15 '23
might even be my own code
1
u/tcbenkhard Jan 15 '23
Why did they even invent the try catch, it's so annoying!
0
u/[deleted] Jan 15 '23
[deleted] — view deleted comment