+ 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?

27th Nov 2017, 2:47 PM
᠌᠌Code X
᠌᠌Code X - avatar
18 Respostas
+ 19
@Brains it must have been : As a string "false" is : correct ans is : truthy.
27th Nov 2017, 3:37 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 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 đŸ€ŁđŸ€ŁđŸ€ŁđŸ€ŁđŸ€Ł
28th Dec 2017, 6:27 PM
🌛DT🌜
🌛DT🌜 - avatar
+ 6
if "false" is taken as string it's truthy if false is taken as boolean it's false.
27th Nov 2017, 6:35 PM
Uttam
Uttam - avatar
+ 5
Jimmy I know it's you Victor sooo....
27th Nov 2017, 3:40 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 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
27th Nov 2017, 3:54 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 4
ok
28th Nov 2017, 6:59 AM
Sid
Sid - avatar
+ 4
that helped a lot
28th Nov 2017, 7:00 AM
Sid
Sid - avatar
+ 4
thanks
28th Nov 2017, 7:00 AM
Sid
Sid - avatar
+ 3
I've cleared my challenge history
27th Nov 2017, 2:57 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 3
ohhh...
28th Nov 2017, 6:46 AM
Sid
Sid - avatar
+ 3
in one of the questions that I did, it said the opposite. Maybe the question was wrong
28th Nov 2017, 6:47 AM
Sid
Sid - avatar
+ 3
No. Question was not wrong.
28th Nov 2017, 6:48 AM
Uttam
Uttam - avatar
28th Nov 2017, 6:49 AM
Uttam
Uttam - avatar
+ 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 :)
28th Nov 2017, 5:13 AM
Jakub MiziƄski
Jakub MiziƄski - avatar
+ 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.
29th Dec 2017, 5:04 AM
Arfaan
Arfaan - avatar
+ 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 😀
29th Dec 2017, 5:06 AM
Arfaan
Arfaan - avatar
+ 1
@sid you are wrong "true" = truthy "false" = truthy
28th Nov 2017, 6:46 AM
Uttam
Uttam - avatar
- 1
"false" = truthy "true" = falsey
28th Nov 2017, 6:44 AM
Sid
Sid - avatar