Last active
February 3, 2016 09:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[3] pry(main)> true.class | |
=> TrueClass | |
[4] pry(main)> false.class | |
=> FalseClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if false == x | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[14] pry(main)> if 0 | |
[14] pry(main)* p 'I am TRUE' | |
[14] pry(main)* end | |
"I am TRUE" | |
=> "I am TRUE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[13] pry(main)> nil.nil? | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment