Skip to content

Instantly share code, notes, and snippets.

@svs
Created November 15, 2012 04:42
Show Gist options
  • Save svs/4076709 to your computer and use it in GitHub Desktop.
Save svs/4076709 to your computer and use it in GitHub Desktop.
# let the argument errors come from the typecast.
# one should not worry about the class of the object, just its capabilities.
def initialize(hash = {})
@name = hash[:name].to_s
@price = hash[:price].to_f
@quantity = Integer(hash[:quantity] || 1)
@list = List.new(hash[:list])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment