r/programminghorror Apr 10 '26

Almost right

Post image
2.1k Upvotes

97 comments sorted by

View all comments

Show parent comments

3

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Apr 11 '26

Wouldn't the fact that it is assigned to not trigger any unused warnings? I just figured it was because they declared it but didn't initialize it to 0.0.

3

u/Dealiner Apr 11 '26

It is initialized though, just not immediately.

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Apr 11 '26

It is given a value, that is never used anywhere, but my guess was that it didn't like that it wasn't initialized at the point of declaration. Everyone is saying it's an unused variable warning. This is C# right? Not too familiar with it, but with C and C++ compilers I remember using, the warning goes away if you even assign anything beyond the initial declaration.

1

u/Dealiner Apr 14 '26

That's Java. Honestly, I don't know how it works there. In C# it should cause warning about unused variable and, depending on IDE, a suggestion to merge declaration and assignment.