種類
- インスタンスメソッド (91)
- クラス (11)
クラス
検索結果
先頭5件
-
Numeric
# eql?(other) -> bool (29108.0) -
自身と other のクラスが等しくかつ == メソッドで比較して等しい場合に true を返します。 そうでない場合に false を返します。
...eric のサブクラスは、eql? で比較して等しい数値同士が同じハッシュ値を返すように
hash メソッドを適切に定義する必要があります。
@param other 自身と比較したい数値を指定します。
//emlist[例][ruby]{
p 1.eql?(1) #=> true
p 1.eql?(......1.0) #=> false
p 1 == 1.0 #=> true
//}
@see Object#equal?, Object#eql?, Object#==, Object#===... -
Bignum
# eql?(other) -> bool (29102.0) -
self と other のクラスが等しくかつ同じ値である場合に true を返します。 そうでない場合に false を返します。
...self と other のクラスが等しくかつ同じ値である場合に true を返します。
そうでない場合に false を返します。
@param other self と比較したい数値。
(1 << 64) == (1 << 64).to_f # => true
(1 << 64).eql?((1 << 64).to_f) # => false... -
String
# eql?(other) -> bool (29102.0) -
文字列の内容が文字列 other の内容と等しいときに true を返します。 等しくなければ false を返します。
...します。
同一のオブジェクトかどうかを比較するわけではありません。
つまり、"string".eql?(str) という式を実行した場合には、
str が "string" という内容の文字列でありさえすれば常に true を返します。
同一のオブジェクト......tring#upcase,
String#downcase で大文字小文字を揃えてから比較してください。
Hash クラス内での比較に使われます。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".eql?(......"STRING") # => false
p "string".eql?("") # => false
p "".eql?("string") # => false
p "string".eql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)
p "string".upcase.eql?("String".upcase) # => tru......合は
String#casecmp? を使ってください。
Hash クラス内での比較に使われます。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".eql?("STRING") # => false
p "string".eql?("")......# => false
p "".eql?("string") # => false
p "string".eql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)
//}
@see Hash, String#<=>, String#casecmp, String#==... -
Time
# eql?(other) -> bool (29102.0) -
other が Time かそのサブクラスのインスタンスであり自身と時刻が等しい場合に true を返します。そうでない場合に false を返します。
...er が Time かそのサブクラスのインスタンスであり自身と時刻が等しい場合に
true を返します。そうでない場合に false を返します。
@param other 自身と比較したい時刻を Time オブジェクトを指定します。
//emlist[][ruby]{
p Time.local......(2000, 1, 1).eql?(Time.local(2000, 1, 1)) # => true
p Time.local(2000, 1, 1).eql?(Time.local(2000, 1, 2)) # => false
//}... -
Regexp
# eql?(other) -> bool (23108.0) -
otherが同じパターン、オプション、文字コードの正規表現であったらtrueを返します。
...らtrueを返します。
@param other 正規表現を指定します。
//emlist[例][ruby]{
p /^eee$/ == /~eee$/x # => false
p /^eee$/ == /~eee$/i # => false
p /^eee$/e == /~eee$/u # => false
p /^eee$/ == Regexp.new("^eee$") # => true
p /^eee$/.eql?(/^eee$/) # => true
//}... -
Numeric (14020.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...値を表す抽象クラスです。Integer や Float などの数値クラス
は Numeric のサブクラスとして実装されています。
演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッド......供されているメソッド
(+, -, *, /, %) を利用して定義されるものがほとんどです。
つまり Numeric で定義されているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce)......表しメソッド定義などではこの記法を利用します。
効率のため Numeric のメソッドと同じメソッドがサブクラスで再定義されている場合があります。
Numeric#coerce メソッドを使うことによって異なる数値クラス間で演算を行... -
String
# hash -> Integer (11118.0) -
self のハッシュ値を返します。 eql? で等しい文字列は、常にハッシュ値も等しくなります。
...self のハッシュ値を返します。
eql? で等しい文字列は、常にハッシュ値も等しくなります。
//emlist[例][ruby]{
"test".hash # => 4038258770210371295
("te" + "st").hash == "test".hash # => true
//}
@see Hash... -
Hash
# assoc(key) -> Array | nil (8108.0) -
ハッシュが key をキーとして持つとき、見つかった要素のキーと値のペア を配列として返します。
...を配列として返します。
キーの同一性判定には eql? メソッドではなく == メソッドを使います。
key が見つからなかった場合は、nil を返します。
@param key 検索するキー
//emlist[例][ruby]{
h = {"colors" => ["red", "blue", "green"],
"......letters" => ["a", "b", "c" ]}
h.assoc("letters") #=> ["letters", ["a", "b", "c"]]
h.assoc("foo") #=> nil
//}
@see Array#assoc... -
Method
# hash -> Integer (8108.0) -
自身のハッシュ値を返します。
...自身のハッシュ値を返します。
//emlist[例][ruby]{
a = method(:==)
b = method(:eql?)
p a.eql? b # => true
p a.hash == b.hash # => true
p [a, b].uniq.size # => 1
//}... -
UnboundMethod
# hash -> Integer (8108.0) -
自身のハッシュ値を返します。
...自身のハッシュ値を返します。
//emlist[例][ruby]{
a = method(:==).unbind
b = method(:eql?).unbind
p a.eql? b # => true
p a.hash == b.hash # => true
p [a, b].uniq.size # => 1
//}...