Created
August 6, 2011 19:31
-
-
Save tijn/1129666 to your computer and use it in GitHub Desktop.
a self-describing program
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
# The == comparison operator checks whether two values are equal. | |
true == true | |
'==' == '==' | |
# eql? checks if two values are equal and of the same type. | |
true.eql? true | |
"eql?".eql?("eql?") | |
# equal? checks if two things are one and the same object. | |
"equal?".equal?("equal?") | |
x = 'equal?' and x.equal?(x) | |
# How do I remember which is which ... The longer the operator, the more restrictive the test it performs. | |
# --------- | |
File.readlines(__FILE__).each do |line| | |
break if line =~ /^# -----/ | |
puts line | |
result = eval(line) | |
puts "=> #{result}" unless result.nil? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment