Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View wtf.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
class Foo
 
def bar(*args)
attribute(:bar, *args)
end
 
def attribute(name)
puts name
end
 
end
 
foo = Foo.new
 
begin
foo.bar(100)
rescue => e
puts e.class.name
end
 
foo.bar # legit
 
5.times do
foo.bar(100)
end
 
puts 'No errors??? WTF???'
Owner

ruby >= 2.0 output:

ArgumentError
bar
bar
bar
bar
bar
bar
No errors??? WTF???

ruby 1.8.7 (anything < 2.0) output:

ArgumentError
bar
(eval):3:in `attribute': wrong number of arguments (2 for 1) (ArgumentError)
    from (eval):3:in `bar'
    from foo.rb:28
    from foo.rb:27:in `times'
    from foo.rb:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.