Slide 64
Slide 64 text
$ ruby -v
ruby 1.9.4dev (2011-09-28 trunk 33354) [x86_64-darwin10.8.0]
$ irb --simple-prompt
>> (1.0 .. 12.7).step(1.3).to_a
=> [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7]
>> (1.0 .. 12.7).step(1.3).map(&:class)
=> [Rational, Rational, Rational, Rational, Rational, Rational,
Rational, Rational, Rational, Rational]
>> (1.0 ... 128.4).step(18.2).to_a
=> [1.0, 19.2, 37.4, 55.6, 73.8, 92.0, 110.2]
>> (1.0 ... 128.4).step(18.2).to_a.size
=> 7
>> (1 ... 1284.quo(10)).step(182.quo(10)).to_a
=> [1, (96/5), (187/5), (278/5), (369/5), (92/1), (551/5)]
>> (1 ... 1284.quo(10)).step(182.quo(10)).to_a.size
=> 7
50
Monday, October 10, 11