ga-wdi-boston / ruby-hash

Other
0 stars 79 forks source link

Redundancy on default hash value #3

Closed gaand closed 7 years ago

gaand commented 8 years ago
> apartment = Hash.new('')
=> {}
> apartment.default = ''
''

Maybe show that the first and use the second to demonstrates it's value before making use of that value?

neugierige commented 8 years ago

Agreed. So get rid of apartment = Hash.new('') and only do apartment.default = '' in the demo?

neugierige commented 8 years ago

As per conversation with @gaand, apartment = Hash.new('') is preferred.

MicFin commented 7 years ago

@gaand the current code along is

> apartment = {}
=> {}
> apartment = Hash.new
=> {}
> apartment = Hash.new('')
=> {}
> apartment.default = ''
=> ""
> apartment[:address]
=> ""
> apartment[:address] = { street: '255 Long Road', city: 'Awesomeville', bedrooms: 3}
=> {:street=>"255 Long Road", :city=>"Awesomeville", :bedrooms=>3}
> apartment.merge({rent: 1000})
=> {:street=>"255 Long Road", :city=>"Awesomeville", :bedrooms=>3, :rent=>1000}

Based on the issue comments, is it preferable to remove apartment.default = ''? So the code-a-long would be:

> apartment = {}
=> {}
> apartment = Hash.new
=> {}
> apartment = Hash.new('')
=> {}
> apartment[:address]
=> ""
> apartment[:address] = { street: '255 Long Road', city: 'Awesomeville', bedrooms: 3}
=> {:street=>"255 Long Road", :city=>"Awesomeville", :bedrooms=>3}
> apartment.merge({rent: 1000})
=> {:street=>"255 Long Road", :city=>"Awesomeville", :bedrooms=>3, :rent=>1000}
jrhorn424 commented 7 years ago

Based on the issue comments, is it preferable to remove apartment.default = ''?

That's how I'm reading it. I'll wait for @gaand to chime in.

Thanks for asking before removing something!

gaand commented 7 years ago

That was the intent.