Skip to content

Instantly share code, notes, and snippets.

@sugamasao
Created July 27, 2020 09:24
Show Gist options
  • Save sugamasao/f0da58f93d436b6b559fc2d1a07b32f2 to your computer and use it in GitHub Desktop.
Save sugamasao/f0da58f93d436b6b559fc2d1a07b32f2 to your computer and use it in GitHub Desktop.
struct
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