Skip to content

Instantly share code, notes, and snippets.

@giwa
Last active February 3, 2016 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giwa/7996ca341b74d21148a3 to your computer and use it in GitHub Desktop.
Save giwa/7996ca341b74d21148a3 to your computer and use it in GitHub Desktop.
Understand What Ruby considers to be True ref: http://qiita.com/giwa/items/8d083c48152bdb99f3fa
[3] pry(main)> true.class
=> TrueClass
[4] pry(main)> false.class
=> FalseClass
if false == x
...
end
[5] pry(main)> class Bad
[5] pry(main)* def == (other)
[5] pry(main)* true
[5] pry(main)* end
[5] pry(main)* end
=> :==
[6] pry(main)> false == Bad.new
=> false
[7] pry(main)> Bad.new == false
=> true
[14] pry(main)> if 0
[14] pry(main)* p 'I am TRUE'
[14] pry(main)* end
"I am TRUE"
=> "I am TRUE"
[13] pry(main)> nil.nil?
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment