第二天练习
散列->数组:keys,values, to_a
练习1,
a = (1..16).to_a
使用each
n = 1a.each do |i| if n%4 != 0 print i print " " else puts i end n = n + 1end
使用each_slice
a.each_slice(4){|i| p i}
练习2
第二天练习
散列->数组:keys,values, to_a
练习1,
a = (1..16).to_a
使用each
n = 1a.each do |i| if n%4 != 0 print i print " " else puts i end n = n + 1end
使用each_slice
a.each_slice(4){|i| p i}
练习2