るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.017秒)
トップページ > クエリ:FALSE[x] > クエリ:NIL[x] > クエリ:<=>[x] > クラス:Range[x]

別のキーワード

  1. object false
  2. _builtin false
  3. rb_false
  4. false object
  5. false

ライブラリ

検索結果

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

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

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

//emlist[例: 整数の範囲オブジェクトの場合][ruby]{
Range
.new(1, 10) # => 1..10
Range
.new(1, 10, true) # => 1...10
//}

//emlist[例: 日付オブジェクトの範囲オブジェクトの場合][ruby]{
require 'date'
Range
.new(...
...e 'ipaddr'
Range
.new(IPAddr.new("192.0.2.1"), IPAddr.new("192.0.2.3")).each {|ip| puts ip}
# => 192.0.2.1
# 192.0.2.2
# 192.0.2.3
//}

//emlist[例: 自作のオブジェクトの場合][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
# 3
//}...