+ 5
The boolean 'False'
I was doing ruby challenge and I failed a question which asked what the value of false was!After the challenge i discovered false evaluates to truth soo... Why does the boolean 'false' evaluate to truth in ruby?
19 Réponses
+ 19
@Brains it must have been :
As a string "false" is :
correct ans is : truthy.
+ 9
@🌞 Brains
In Ruby only false & nil are falsey , everything else is truthy ..😊😊😊
the que u r referring in that
false is taken as string "false". so its truthy😎😎😎
I hope u start challenging me in Ruby😎 bro...!!
I will solve all ur doubts 🤣🤣🤣🤣🤣
+ 6
if "false" is taken as string it's truthy
if false is taken as boolean it's false.
+ 5
Jimmy I know it's you Victor sooo....
+ 4
You are the dumbest friend I have😂😂you open an account and immediately the first thing you do is comment on my post?and you think I wouldn't suspect?FAIL
+ 4
ok
+ 4
that helped a lot
+ 4
thanks
+ 3
I've cleared my challenge history
+ 3
ohhh...
+ 3
in one of the questions that I did, it said the opposite. Maybe the question was wrong
+ 3
No. Question was not wrong.
+ 3
@sid see this
https://www.sololearn.com/discuss/875001/?ref=app
+ 2
Well, there are two objects in Ruby that evaluates to false.
1) nil
2) false (as a boolean value)
I suppose that in challenge there is about "false" string, which evaluates to true.
This is tricky question, but still valid, and even cool imo :)
+ 2
Apart from true and false, if you try to evaluate something that is not a boolean, ruby will treat them as truthy and falsey. Only false and nil are falsey, everything else is truthy. The boolean false is obviously false, but if it is a string “false”, then ruby treats it as truthy.
+ 2
@Deoanshu Thakur Sorry if you don’t like me always challenging you 😅I don’t know why but I like to challenge someone who is better than me. If you think I am spamming and disturbing you, please let me know. I will stop challenging you then 😀
+ 1
@sid you are wrong
"true" = truthy
"false" = truthy
- 1
"false" = truthy
"true" = falsey