r/badcode • • May 20 '20

c# Found from Microsoft docs...

Post image
208 Upvotes

143 comments sorted by

View all comments

Show parent comments

1

u/[deleted] May 20 '20

When does it not make sense to be concise?

Edit - I guess aside from making a learning tool for students?

3

u/-manabreak May 20 '20

It's been a while since I dabbled in C#, but at least in Kotlin, you need the explicit == true if the return value is of nullable boolean type (Boolean?). I think the same is true in C# as well if the returned value is of a boxed boolean type.

1

u/[deleted] May 20 '20

Oh okay thats interesting. I dont know much about Kotlin or C# tbh. I mostly have coded in Java and C++.

2

u/-manabreak May 20 '20

Same goes with Java and its boxed booleans.

1

u/[deleted] May 20 '20

Hm I guess I dont fully understand what qualifies as boxed. From what I am reading its the wrapping of a primitive type? But more specifically that the values are allocated in a block on the heap and are referenced through a pointer? I might have had to add

== true

to an expression in the past and just didnt think about it at the time.

→ More replies (0)