Skip to content

Instantly share code, notes, and snippets.

@tomohiro
Forked from gongo/gongo.rb
Created June 2, 2010 09:13
Show Gist options
  • Save tomohiro/422136 to your computer and use it in GitHub Desktop.
Save tomohiro/422136 to your computer and use it in GitHub Desktop.
[] メソッド実装例
class Gongo
def [](v)
self.class.[] (v)
end
def self.[](v)
v * 3
end
end
puts Gongo['du']
gongo = Gongo.new
puts gongo['du']
#
# % ruby gongo.rb
# dududu
# dududu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment