11件ヒット
[1-11件を表示]
(0.019秒)
検索結果
-
Range
. new(first , last , exclude _ end = false) -> Range (19.0) -
first から last までの範囲オブジェクトを生成して返しま す。
...ト
@param exclude_end 真をセットした場合終端を含まない範囲オブジェクトを生成します
@raise ArgumentError first <=> last が nil の場合に発生します
//emlist[例: 整数の範囲オブジェクトの場合][ruby]{
Range.new(1, 10) # => 1..10
Range.new(1,......[例: 自作のオブジェクトの場合][ruby]{
MyInteger = Struct.new(:value) do
def succ
self.class.new(value + 1)
end
def <=>(other)
value <=> other.value
end
def to_s
value.to_s
end
end
Range.new(MyInteger.new(1), MyInteger.new(3)).each {|i| puts i }
# => 1
# 2
#...