Skip to content

Instantly share code, notes, and snippets.

@CoryFoy
Created January 21, 2015 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CoryFoy/18c8bb9edd58043bea86 to your computer and use it in GitHub Desktop.
Save CoryFoy/18c8bb9edd58043bea86 to your computer and use it in GitHub Desktop.
class Foo
def initialize(str)
@str = str
end
def *(num)
num.times.map { @str }.join('')
end
end
foo = Foo.new('hello')
foo * 4 #=> "hellohellohellohello"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment