Skip to content

Instantly share code, notes, and snippets.

@ticktricktrack
Created December 7, 2010 16:17
Show Gist options
  • Save ticktricktrack/731978 to your computer and use it in GitHub Desktop.
Save ticktricktrack/731978 to your computer and use it in GitHub Desktop.
exercise1_by_ray_attempt_2.rb
class I
def like arg
puts "%s %s %s" % [self.class, self.class.instance_methods(false), arg]
end
end
c, m, arg = gets.split # input 'I like metaprogramming.'
puts
# If I can't modify the like method itself, let's modify what it calls
Class.send(:define_method, :instance_methods){|args| super(args).first.to_s}
Object.const_get(c).new.send(m,arg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment