Created
August 13, 2018 23:38
-
-
Save bernardeli/e4762d2a423a72d158fbc97c20e1da49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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