Created
April 26, 2012 14:47
-
-
Save jamesgecko/2500081 to your computer and use it in GitHub Desktop.
case matches using ===
This file contains hidden or 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
unknown, String, foo | |
unknown, Fixnum, 42 | |
unknown, Array, |
This file contains hidden or 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
def exec_update(*params) | |
if params.empty? | |
puts 'empty' | |
else | |
params.each_with_index do |p, i| | |
case p | |
when String | |
puts 'string' | |
when Fixnum | |
puts 'int' | |
else | |
puts "unknown, #{p.class.to_s}, #{p.to_s}" | |
end | |
end | |
end | |
end | |
exec_update('foo', 42, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment