るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.008秒)
トップページ > ライブラリ:date[x] > バージョン:2.4.0[x] > クラス:Date[x] > クエリ:<=>[x]

別のキーワード

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

検索結果

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

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

...

//emlist[][ruby]{
require "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(49...