Tag: block

人们一直在告诉我,我正在用ruby写“C风格迭代器”,我应该这样做,没有i ++的东西

这里的细节并不重要,它只是一个例子,重要的是i = 0,i + = 1动作 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 […]