解决方法
我强烈建议使用.each,.inject和/或.collect.例如:
# Sum 1,3,5,7,9,11,13 [1,13].inject { |a,b| a+b }
要么
# Print out all of the files in a directory Dir.glob('./my_cool_directory/*').each do |file| puts file end
要么
# Find the length of all of the strings ["test","hello there","how's life today?"].collect{ |string| string.length }