Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.



Ruby 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]]




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: