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?
11/27/2017 2:47:44 PM
᠌᠌Brains[Abidemi]19 Answers
New Answer@Brains it must have been : As a string "false" is : correct ans is : truthy.
@🌞 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 🤣🤣🤣🤣🤣
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
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 :)
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.
@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 😀
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message