るりまサーチ

最速Rubyリファレンスマニュアル検索!
852件ヒット [1-100件を表示] (0.187秒)
トップページ > クエリ:-[x] > クエリ:E[x] > クエリ:ruby[x] > クエリ:<=>[x]

別のキーワード

  1. open3 popen2e
  2. socket af_e164
  3. matrix det_e
  4. matrix rank_e
  5. open3 capture2e

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

self と other を比較して、
self が other の子孫であるとき -1、
同一のクラス/モジュールのとき 0、
self が other の先祖であるとき 1
を返します。

継承関係にないクラス同士の比較では
n...
...other がクラスやモジュールでなければ
nil を返します。

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

//emlist[例][ruby]{
module Foo
e
nd
class Bar
include Foo
e
nd
class Baz < Bar
e
nd
class Qux
e
nd
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
//}...

Time#<=>(other) -> -1 | 0 | 1 | nil (21419.0)

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

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

@param other 自身と比較したい時刻を Time オブジェクトで指定します。...
...//emlist[][ruby]{
p t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p t2 = t + 2592000 # => 2000-01-31 00:00:00 +0900
p t <=> t2 # => -1
p t2 <=> t # => 1
//}

//emlist[][ruby]{
p t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p t2 = t + 0.1 # =>...
...2000-01-01 00:00:00 +0900
p t.nsec # => 0
p t2.nsec # => 100000000
p t <=> t2 # => -1
p t2 <=> t # => 1
p t <=> t # => 0
//}...

Date#<=>(other) -> -1 | 0 | 1 | nil (21360.0)

二つの日付を比較します。 同じ日付なら 0 を、self が other よりあとの日付なら 1 を、 その逆なら -1 を返します。

...self が other よりあとの日付なら 1 を、
その逆なら -1 を返します。

other は日付オブジェクトか、
天文学的なユリウス日をあらわす数値を指定します。
そうでない場合、比較ができないので nil を返します。

//emlist[][ruby]{
re...
...quire "date"

p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 4) # => -1
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 3) # => 0
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 2) # => 1
p Date.new(2001, 2, 3) <=> Object.new # => nil
p Date.new(2001, 2, 3) <=> Rational(4903887, 2) # => 0
//}

@pa...
...ram other 日付オブジェクトまたは数値...

Complex#<=>(other) -> -1 | 0 | 1 | nil (21359.0)

self の虚部がゼロで other が実数の場合、 self の実部の <=> メソッドで other と比較した結果を返します。 other が Complex で虚部がゼロの場合も同様です。

...self の虚部がゼロで other が実数の場合、
self の実部の <=> メソッドで other と比較した結果を返します。
other が Complex で虚部がゼロの場合も同様です。

その他の場合は nil を返します。

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

//emlis...
...t[例][ruby]{
Complex(2, 3) <=> Complex(2, 3) #=> nil
Complex(2, 3) <=> 1 #=> nil
Complex(2) <=> 1 #=> 1
Complex(2) <=> 2 #=> 0
Complex(2) <=> 3 #=> -1
//}...

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

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

...self と other を比較して、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
//}...

絞り込み条件を変える

OpenSSL::BN#<=>(other) -> -1 | 0 | 1 (21354.0)

自身と other を比較し、自身が小さいときには -1、 等しいときには 0、大きいときには 1 を返します。

...と other を比較し、自身が小さいときには -1、
等しいときには 0、大きいときには 1 を返します。

//emlist[][ruby]{
require 'openssl'

OpenSSL::BN.new(5) <=> 5 # => 0

OpenSSL::BN.new(5) <=> OpenSSL::BN.new(9) # => -1
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(5) #...
...=> 0
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(-5) # => 1
//}

@param other 比較する整数
@raise TypeError 比較できないときに発生します。
@see OpenSSL::BN#ucmp...

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

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

...self と other を比較して、self が小さい時に -1、
等しい時に 0、大きい時に 1 の整数を返します。
また、other が Gem::Version ではなく比較できないとき、 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
//}

@param other 比較対象の Gem::Version のインスタンスを指定します。...

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

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

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

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

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

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

Pathname#<=>(other) -> -1 | 0 | 1 | nil (21331.0)

パス名を比較します。other と同じなら 0 を、ASCII順で self が大きい場合 は正、other が大きい場合は負を返します。大文字小文字は区別されます。 other は Pathname オブジェクトでなければなりません。

...パス名を比較します。other と同じなら 0 を、ASCII順で self が大きい場合
は正、other が大きい場合は負を返します。大文字小文字は区別されます。
other は Pathname オブジェクトでなければなりません。

パス名の比較は単純に...
...er 比較対象の Pathname オブジェクトを指定します。

//emlist[例][ruby]{
require 'pathname'

p Pathname.new("foo/bar") <=> Pathname.new("foo/bar")
p Pathname.new("foo/bar") <=> Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") <=> Pathname.new("foo/bar")
# => 0
# 1
# -...

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

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

...self が other よりも
新しければ正の数を、等しければ 0 を古ければ負の数を返します。
比較できない場合は 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
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>