Ruby 'Range.last' does not give the last value. Why?

Viewed 1492

When using the triple dot notation in a ruby Range object, I get this:

(0...5).each{|n| p n}
0
1
2
3
4

When I use the 'last' method I get:

(0...5).last
 => 5 

I would have expected 4

Is this is a bug? Or is there something I don't understand about the the concept of a Range object?

2 Answers
Related