Next | 3.1 Numbers | Prev |
number = 20 5.times do print number.class, " ", number, "\n" number *= number end |
Fixnum 20 Fixnum 400 Fixnum 160000 Bignum 25600000000 Bignum 655360000000000000000 |
3.times { print "Hey! " } 15.downto(12) { |i| print i, " " } 30.step(40, 5) { |i| print i, " " } |
Hey! Hey! Hey! 15 14 13 12 30 35 40 |
nums = "19:45".split(':') printf "Minutes: %d\n", nums[0] * 60 + nums[1] |
Minutes: 191919191919...191919191945 |
Should be written as:
nums = "19:45".split(':') printf "Minutes: %d\n", nums[0].to_i * 60 + nums[1].to_i |
Minutes: 1185 |
Next | Ruby for Perl programmers | Prev |