Created
August 29, 2011 20:47
-
-
Save hexgnu/1179368 to your computer and use it in GitHub Desktop.
Dont ever do this evar!!!
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
#!/usr/bin/env ruby -w | |
class Foo; end | |
f = Foo.new | |
f.instance_eval do | |
class << self | |
attr_accessor :baz | |
end | |
end | |
f.baz #=> nil | |
f.baz = 'zomg' | |
f.baz #=> 'zomg' | |
g = Foo.new | |
begin | |
g.baz | |
rescue NoMethodError | |
puts 'There is no method BAZ!!!' | |
end | |
begin | |
g.baz = 'ugh' | |
rescue NoMethodError | |
puts 'Seriously why would you ever do this?!!' | |
end | |
puts 'WHAT THE FUCK MAN' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment