Created
July 27, 2020 09:24
-
-
Save sugamasao/f0da58f93d436b6b559fc2d1a07b32f2 to your computer and use it in GitHub Desktop.
struct
This file contains hidden or 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
Person = Struct.new(:name, :age, keyword_init: true) do | |
def greet | |
puts "#{name} : #{age}" | |
end | |
end | |
person = Person.new(name: 'taro', age: 20) | |
person.greet #=> taro : 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment