Skip to content

Instantly share code, notes, and snippets.

@nashby
Created August 23, 2011 21:00
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 nashby/1166517 to your computer and use it in GitHub Desktop.
Save nashby/1166517 to your computer and use it in GitHub Desktop.
def attributes
attrs = {}
attribute_names.each { |name| attrs[name] = read_attribute(name) }
attrs
end
#vs
def attributes
attribute_names.inject({}) { |attrs, name| attrs[name] = read_attribute(name); attrs }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment