Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
This is evil!
But the "maybe" is not the problem.
Enums are typically only an abstraction to numbers, starting at zero. This makes "maybe" a 2, which is always true, so no problem.
But "true" and "false"... they are switched! Here "true" is 0 and "false" is 1. That is going to make a lot of problems. -
SomeNone7135yObligatory TDWTF plug:
https://thedailywtf.com/articles/..._
enum Bool
{
True,
False,
FileNotFound
}; -
Geoxion9035y@Benedikt who says that 2 is true? Or even that 1 is true? Who says that booleans even have a numerical representation? 😉😇
-
Geoxion9035y@Benedikt on the hardware, yes. But that doesn't mean the abstracted language type has to.
-
Geoxion9035y@010001111 in Rust, you can't convert a number to a bool directly. You need to do a comparison like 'let b: bool = num > 0;'.
-
@Geoxion Just yesterday I was telling my boss that I‘ll turn off no-implicit-type-coercion because at least in web frontend it’s 80% just „is it there?“
Now I hate Rust, thanks. -
Geoxion9035y@010001111 No don't! Compilers should have all the warnings and errors turned on, because they are actually almost every time right. It'll save you a lot of debugging.
-
Ah, good old true, false & null.
I wish I could murder null with a dull rusty hacksaw. Speaking of Rust... have you heard of our lord and savior ERROR[E0381]: BORROW OF POSSIBLY-UNINITIALIZED VARIABLE
Related Rants
Could this be true?
joke/meme
boolean logic