4 ms·
> I don't think that allowing you to iterate over a hash as if it were an array is all that unforgivable Ruby allows this. Both arrays and hashes provide an ea
by epochwolf 15y ago
> I don't think that allowing you to iterate over a hash as if it were an array is all that unforgivable
Ruby allows this. Both arrays and hashes provide an each method and include the Enumerable module.
- deleted 15y ago[deleted]
- JulianMorrison 15y agoRuby even makes it invisible because of destructuring assignment of block variables. ruby-1.9.2-p180 > {1=>2}.each {|k,v| puts "#{k} #{v}"} 1 2 => {1=>2} ruby-1.9.2-p180 > {1=>2}.sort.each {|k,v| puts "#{k} #{v}"} 1 2 => [[1, 2]]