带序号循环Hash
带序号循环HashRuby代码1.hash.keys.each_with_index do |key, index|
2. value = hash
3. print "key: #{key}, value: #{value}, index: #{index}\n"
4. # use key, value and index as desired
5.end
hash.keys.each_with_index do |key, index|
value = hash
print "key: #{key}, value: #{value}, index: #{index}\n"
# use key, value and index as desired
endRuby代码1.hash.each_with_index do |(key, value), index|
2. print "key: #{key}, value: #{value}, index: #{index}\n"
3. # use key, value and index as desired
4.end 谢谢分享希望于楼主多多交流 老发重复的帖子。
页:
[1]