Which of the expressions listed below will result in “false”?

Technology CommunityCategory: RubyWhich of the expressions listed below will result in “false”?
VietMX Staff asked 3 years ago
Problem
true    ? "true" : "false"
false   ? "true" : "false"
nil     ? "true" : "false"
1       ? "true" : "false"
0       ? "true" : "false"
"false" ? "true" : "false"
""      ? "true" : "false"
[]      ? "true" : "false"

In Ruby, the only values that evaluate to false are false and nilEverything else – even zero (0) and an empty array ([]) – evaluates to true.

This comes as a real surprise to programmers who have previously been working in other languages like JavaScript.