るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.024秒)
トップページ > クエリ:<=>[x] > ライブラリ:ビルトイン[x] > 種類:特異メソッド[x]

別のキーワード

  1. _builtin <=>
  2. date <=>
  3. ipaddr <=>
  4. openssl <=>

クラス

検索結果

Range.new(first, last, exclude_end = false) -> Range (15.0)

first から last までの範囲オブジェクトを生成して返しま す。

...ェクト
@param exclude_end 真をセットした場合終端を含まない範囲オブジェクトを生成します

@raise ArgumentError first <=> last が nil の場合に発生します

//emlist[例: 整数の範囲オブジェクトの場合][ruby]{
Range.new(1, 10) # => 1..10
Range.n...
...[例: 自作のオブジェクトの場合][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
#...