るりまサーチ

最速Rubyリファレンスマニュアル検索!
465件ヒット [1-100件を表示] (0.038秒)

別のキーワード

  1. _builtin nil?
  2. nilclass nil?
  3. object nil?
  4. _builtin nil
  5. object nil

検索結果

<< 1 2 3 ... > >>

Module#<=(other) -> bool | nil (18249.0)

比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。

...、 true を返します。
self が other の先祖である場合、false を返します。

継承関係にないクラス同士の比較では
nil
を返します。

@param other 比較対象のモジュールやクラス

@raise TypeError other がクラスやモジュールではない場合...
...ule#<

//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend Foo
end

Bar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
Bar <= Foo # => true

Baz.ancestors # => [Foo, Baz]
Foo <= Baz # => false
Baz <= Foo # => true

Foo <= Foo # => true
Foo <= Object # => nil
//}...

Comparable#<=(other) -> bool (18124.0)

比較演算子 <=> をもとにオブジェクト同士を比較します。 <=> が負の整数か 0 を返した場合に、true を返します。 それ以外の整数を返した場合に、false を返します。

...比較演算子 <=> をもとにオブジェクト同士を比較します。
<=
> が負の整数か 0 を返した場合に、true を返します。
それ以外の整数を返した場合に、false を返します。

@param other 自身と比較したいオブジェクトを指定します。...
...@raise ArgumentError <=> が nil を返したときに発生します。

//emlist[例][ruby]{
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true
//}...

Rational#<=>(other) -> -1 | 0 | 1 | nil (6235.0)

self と other を比較して、self が大きい時に 1、等しい時に 0、小さい時に -1 を返します。比較できない場合はnilを返します。

...合はnilを返します。

@param other 自身と比較する数値

@return -1 か 0 か 1 か nil を返します。

//emlist[例][ruby]{
Rational(2, 3) <=> Rational(2, 3) # => 0
Rational(5) <=> 5 # => 0
Rational(2, 3) <=> Rational(1,3) # => 1
Rational(1, 3) <=> 1...
...# => -1
Rational(1, 3) <=> 0.3 # => 1
Rational(1, 3) <=> nil # => nil
//}...

Module#<=>(other) -> Integer | nil (6231.0)

self と other の継承関係を比較します。

...
nil
を返します。

other がクラスやモジュールでなければ
nil
を返します。

@param other 比較対象のクラスやモジュール

//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar <=> Foo # => -1
p Baz <=> Bar...
...# => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=> Object.new # => nil
//}...

Float#<=>(other) -> -1 | 0 | 1 | nil (6229.0)

self と other を比較して、self が大きい時に正、 等しい時に 0、小さい時に負の整数を返します。 比較できない場合はnilを返します

...self が大きい時に正、
等しい時に 0、小さい時に負の整数を返します。
比較できない場合はnilを返します

//emlist[例][ruby]{
3.05 <=> 3.14 # => -1
1.732 <=> 1.414 # => 1
3.3 - 3.3 <=> 0.0 # => 0
3.14 <=> "hoge" # => nil
3.14 <=> 0.0/0.0 # => nil
//}...

絞り込み条件を変える

Integer#<=>(other) -> -1 | 0 | 1 | nil (6229.0)

self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。

...、self が大きい時に1、等しい時に 0、小さい時
に-1、比較できない時に nil を返します。

@param other 比較対象の数値
@return -1 か 0 か 1 か nil のいずれか

//emlist[][ruby]{
1 <=> 2 # => -1
1 <=> 1 # => 0
2 <=> 1 # => 1
2 <=> '' # => nil
//}...

File::Stat#<=>(o) -> Integer | nil (6223.0)

ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。

... nil を返します。

@param o File::Stat のインスタンスを指定します。

//emlist[][ruby]{
require 'tempfile' # for Tempfile

fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"

p File::Stat.new(fp1.path) <=> File...
...::Stat.new(fp2.path) #=> -1
p File::Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}...

Gem::Version#<=>(other) -> -1 | 0 | 1 | nil (6223.0)

self と other を比較して、self が小さい時に -1、 等しい時に 0、大きい時に 1 の整数を返します。 また、other が Gem::Version ではなく比較できないとき、 nil を返します。

... nil を返します。

//emlist[][ruby]{
p Gem::Version.new("3.9.0") <=> Gem::Version.new("3.10.0") # => -1
p Gem::Version.new("3.0.0") <=> Gem::Version.new("3.0.0") # => 0
p Gem::Version.new("3.0.0") <=> Gem::Version.new("3.0") # => 0

p Gem::Version.new("3.9.0") <=> "3.9.0" # => nil
//}...

Numeric#<=>(other) -> -1 | 0 | 1 | nil (6223.0)

自身が other より大きい場合に 1 を、等しい場合に 0 を、小さい場合には -1 をそれぞれ返します。 自身と other が比較できない場合には nil を返します。

...には nil を返します。

Numeric のサブクラスは、上の動作を満たすよう このメソッドを適切に再定義しなければなりません。

@param other 自身と比較したい数値を指定します。

//emlist[例][ruby]{
1 <=> 0 #=> 1
1 <=> 1 #=> 0
1 <=> 2 #=>...
...-1
1 <=> "0" #=> nil
//}...

Object#<=>(other) -> 0 | nil (6223.0)

self === other である場合に 0 を返します。そうでない場合には nil を返します。

...self === other である場合に 0 を返します。そうでない場合には nil を返します。

//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}

@see Object#===...

絞り込み条件を変える

<< 1 2 3 ... > >>