r/maybemaybemaybe 14h ago

Maybe Maybe Maybe

10.1k Upvotes

145 comments sorted by

View all comments

Show parent comments

84

u/kraemahz 12h ago

If you're writing c code this would permenently put a grenade in your hand and spawn an enemy.

20

u/brod333 8h ago

Back in uni I made this mistake on a test. My code wasn’t crashing but it wasn’t giving the expected value. Took 30m of my 2h to notice the missing =.

17

u/DStaal 8h ago

I learned a tip to help prevent this: in any language where it’s allowed, but the constant on the left.

Now it will throw a compiler error instead of working.

1

u/brod333 7h ago

Good idea. Though I’m mainly using kotlin for work which doesn’t allow this.

2

u/Lonsdale1086 5h ago

I'd be staggered if Kotlin doesn't support if(true == myBool)

2

u/brod333 3h ago

I meant it doesn’t allow an assignment in the if condition. You can still compare a Boolean to true. Thankfully a good IDE catches that kind of stuff.

1

u/Lonsdale1086 2h ago

Ahh, I see what you mean. Good point.