Was wird in Ruby als falsch bewertet?

false undnil bewerten zufalsch imRuby. Noch etwas? Bitte geben Sie Links zu offiziellen / maßgeblichen Referenzen an.

2.0.0p247 :001 > if true ; puts 'TRUE' ; else puts 'FALSE' ; end
TRUE

2.0.0p247 :002 > if false ; puts 'TRUE' ; else puts 'FALSE' ; end
FALSE

2.0.0p247 :003 > if nil ; puts 'TRUE' ; else puts 'FALSE' ; end
FALSE

2.0.0p247 :004 > if 0 ; puts 'TRUE' ; else puts 'FALSE' ; end
TRUE

2.0.0p247 :005 > if [] ; puts 'TRUE' ; else puts 'FALSE' ; end
TRUE

2.0.0p247 :006 > if {} ; puts 'TRUE' ; else puts 'FALSE' ; end
TRUE

2.0.0p247 :007 > if '' ; puts 'TRUE' ; else puts 'FALSE' ; end
(irb):616: warning: string literal in condition
TRUE

Antworten auf die Frage(4)

Ihre Antwort auf die Frage