Skip to content

Instantly share code, notes, and snippets.

@rudolph9
Created September 27, 2012 14:45
Show Gist options
  • Save rudolph9/3794402 to your computer and use it in GitHub Desktop.
Save rudolph9/3794402 to your computer and use it in GitHub Desktop.
Ruby Method Overloading Example
[1] pry(main)> puts "hello world!"
hello world!
=> nil
[2] pry(main)> class << self
[2] pry(main)* def puts string
[2] pry(main)* print "overloaded! " + string + "\n"
[2] pry(main)* end
[2] pry(main)* end
=> nil
[3] pry(main)> puts "hello world!"
overloaded! hello world!
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment