1、循环执行的简易写法
10.times do (1..10).each do | n | puts "哈哈哈#{n}" end end
2、数组中增加元素
a = Array[1,2,2,4,4,44,445,5] a << 3
3、取随机的整数
l = rand(a.length - 1)