+ 7

What is the difference between nil and false in Ruby?

20th May 2018, 1:52 PM
Prabhat
Prabhat - avatar
2 ответов
+ 1
null means no data value but memory is still allocated for null. false is a boolean, it is simply not true.
21st May 2018, 5:03 PM
Apple Blossom
Apple Blossom - avatar
+ 5
" false is false, 0 is an integer, and nil is no value. true is true, 1 is an integer, and nil is no value Numbers, strings, and all other values evaluate to true. nil evaluates to false. However, nil is not strictly equal to false, because false is a boolean datatype while nil has no datatype." Credits: https://www.sololearn.com/Profile/1221076/?ref=app " The differences of the methods nil and false are: - nil cannot be a value, where as a false can be a value - A method returns true or false in case of a predicate, other wise nil is returned. - false is a boolean data type, where as nil is not. - nil is an object for NilClass, where as false is an object of for FalseClass -False is a boolean datatype  Nil is not a data type." Source: https://www.careerride.com/Ruby-nil-vs-false.aspx
20th May 2018, 1:57 PM
Rahul George
Rahul George - avatar