44件ヒット
[1-44件を表示]
(0.030秒)
種類
- インスタンスメソッド (33)
- 文書 (11)
検索結果
先頭4件
-
Rational
# <=>(other) -> -1 | 0 | 1 | nil (39319.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
//}... -
Date
# <=>(other) -> -1 | 0 | 1 | nil (18250.0) -
二つの日付を比較します。 同じ日付なら 0 を、self が other よりあとの日付なら 1 を、 その逆なら -1 を返します。
...いので nil を返します。
//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.ne......w(2001, 2, 3) <=> Rational(4903887, 2) # => 0
//}
@param other 日付オブジェクトまたは数値... -
Numeric
# nonzero? -> self | nil (153.0) -
自身がゼロの時 nil を返し、非ゼロの時 self を返します。
...自身がゼロの時 nil を返し、非ゼロの時 self を返します。
//emlist[例][ruby]{
p 10.nonzero? #=> 10
p 0.nonzero? #=> nil
p 0.0.nonzero? #=> nil
p Rational(0, 2).nonzero? #=> nil
//}
非ゼロの時に self を返すため、自身が 0......理をさせたい場合に以
下のように記述する事もできます。
//emlist[例][ruby]{
a = %w( z Bb bB bb BB a aA Aa AA A )
b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
b #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
//}
@see Numeric#zero?... -
Ruby用語集 (78.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...持つ。
https://mruby.org/
: main
トップレベルにおける self。Object クラスのインスタンスである。
===[a:N] N
: nil
NilClass の唯一のインスタンス。また、そのオブジェクトを指す擬似変数の名前。
論理値としては偽である。......宙船演算子
: spaceship operator
Comparable モジュールが利用する、二つのオブジェクトの順序関係を表す
演算子 <=> の俗称。
: 埋め込みドキュメント
: embedded document
ソースコード中の =begin 行から =end 行まで。コメントとみな......学用語の整数ではなく Integer
クラスのインスタンスを指すことが多いので注意。
例えば 1.0(Float)、1r(Rational)、1+0i(Complex)はいずれも
数学的には 1 を表しており、整数であるが、Integer オブジェクトではない。...