Skip to content

Instantly share code, notes, and snippets.

@asterite
Created May 15, 2014 19:19
Show Gist options
  • Select an option

  • Save asterite/99e6b206acd426fe2b1a to your computer and use it in GitHub Desktop.

Select an option

Save asterite/99e6b206acd426fe2b1a to your computer and use it in GitHub Desktop.
initialize overload
class Foo
def initialize(x : Number)
puts "#{x} is a number!"
end
def initialize(x : String)
puts "#{x} is a string!"
end
end
Foo.new(1) # prints "1 is a number!"
Foo.new("hello") # prints "hello is a string!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment