Skip to content

Instantly share code, notes, and snippets.

@bernardeli
Created August 13, 2018 23:38
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 bernardeli/e4762d2a423a72d158fbc97c20e1da49 to your computer and use it in GitHub Desktop.
Save bernardeli/e4762d2a423a72d158fbc97c20e1da49 to your computer and use it in GitHub Desktop.
Superhero = Struct.new(:name, :real_name, :keyword_init => true) do
def introduce_self
"Hi, I'm #{name}, but my friends call me #{real_name}."
end
end
batman = Superhero.new(real_name: "Bruce", name: "Batman")
puts batman.introduce_self
#=> Hi, I'm Batman, but my friends call me Bruce.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment