Skip to content

Instantly share code, notes, and snippets.

@tijn
Created August 6, 2011 19:31
Show Gist options
  • Save tijn/1129666 to your computer and use it in GitHub Desktop.
Save tijn/1129666 to your computer and use it in GitHub Desktop.
a self-describing program
# 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