Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby - everything evaluates to true

According to the literature I have been reading online, everything evaluates to true in Ruby except false and nil. I am trying to find out what benefits this may have? Thanks

like image 397
nikifi Avatar asked Dec 20 '25 05:12

nikifi


1 Answers

I will sum this advantage up in checking if the user input a value.

PHP:

if($somevalue !== null) { # '' and '0' are falsy.

Ruby:

if somevalue
like image 180
Ry- Avatar answered Dec 22 '25 19:12

Ry-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!