prev - up - next - index

Range

The Range class describes the interval. The range object is created by the range operator (.. or ...). The range object created by .. operator include end. The range object created by ... operator does not include end.

For example:

for i in 1..5
  ...
end

iterates over 1 to 5, including 5. On the other hand, 1...5 iterates over 1 through 4.

The both operands for the range operator must be comparable with <=> opeator. In addition they must have succ method for each operation.

Note That an interval contains both ends.

SuperClass:

Object

Included Modules:

Enumerable

Class Methods:

new(first,last[, exclude_end])

Creates the range object from first to last. Optional third argument specifies whether the range include last or not. If the third argument is ommitted, the range will include the last

Methods:

self === other

Returns true if other is within the range. This operator is mostly used by the case statement.

each {|item| ...}

Iterates over each item within the range.

exclude_end?

Returns true if the range will exclude the end.

first
begin

Returns the start point of the range.

last
end

Returns the end point of the range.

length
size

Returns length of the range (last - first + 1).


prev - up - next - index

matz@netlab.co.jp