Skip to content

Instantly share code, notes, and snippets.

@maxidr
Created December 5, 2012 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maxidr/4215221 to your computer and use it in GitHub Desktop.
Save maxidr/4215221 to your computer and use it in GitHub Desktop.
Ruby struct
# instead of: class User < Struct.new(:first, :last) ... end
User = Struct.new(:first, :last) do
def full
"#{first} #{last}"
end
end
james = User.new('James', 'Gray')
# from https://speakerdeck.com/jeg2/10-things-you-didnt-know-ruby-could-do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment