People keep telling me I'm writing “C style iterators” in ruby, and that I'm supposed to do it this other way, without the i++ thing
问题 The details here aren't important, it's just an example, all that matters is the i=0, i+=1 action def sortAndIndex #sorting keys @disco = Hash[@disco.sort] #basic setup for both input types @years = @disco.keys @albums = @disco.values sum = @years.count #setup for "albums" input @allalbums = [] i = 0 sum.times do thatyear = @years[i] + ", " + @albums[i] @allalbums << thatyear i += 1 end end Now this does work, as should any other "i++" type ("C-style") iterator in ruby or most other languages