ライブラリ
- ビルトイン (336)
クラス
モジュール
- Enumerable (88)
キーワード
- != (11)
- === (29)
- [] (7)
-
_ _ id _ _ (11) -
backtrace
_ locations (11) - call (14)
- eql? (24)
- key (7)
-
marshal
_ dump (11) -
marshal
_ load (11) - max (44)
- min (44)
- pack (16)
-
to
_ h (17)
検索結果
先頭5件
-
Struct
# ==(other) -> bool (26147.0) -
self と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。
...が == メソッドで比較して等しい場合に
true を返します。そうでない場合に false を返します。
@param other self と比較したいオブジェクトを指定します。
//emlist[例][ruby]{
Dog = Struct.new(:name, :age)
dog1 = Dog.new("fred", 5)
dog2 = Dog.new("fre......d", 5)
p dog1 == dog2 #=> true
p dog1.eql?(dog2) #=> true
p dog1.equal?(dog2) #=> false
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位... -
Data
# ==(other) -> bool (26141.0) -
self と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。
...が == メソッドで比較して等しい場合に
true を返します。そうでない場合に false を返します。
@param other self と比較したいオブジェクトを指定します。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
dog1 = Dog.new("Fred", 5)
dog2 = Dog.new("Fr......ed", 5.0)
p 5 == 5.0 # => true
p 5.eql?(5.0) # => false
p dog1 == dog2 # => true
p dog1.eql?(dog2) # => false
p dog1.equal?(dog2) # => false
//}
[注意] 本メソッドの記述は Data のサブクラスのインスタンスに対して呼び
出す事を想定......しています。Data.define は Data のサブクラスを作成する点に
注意してください。
@see Object#==, Data#eql?... -
Exception
# ==(other) -> bool (26141.0) -
自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。
...自身と指定された other のクラスが同じであり、
message と backtrace が == メソッドで比較して
等しい場合に true を返します。そうでない場合に false を返します。
@param other 自身と比較したいオブジェクトを指定します。......tion#exception を実行して変換を試みます。
//emlist[例][ruby]{
require "date"
def check_long_month(month)
return if Date.new(2000, month, -1).day == 31
raise "#{month} is not long month"
end
def get_exception
return begin
yield
rescue => e
e
end
end
results = [2, 2,......is not long month", "2 is not long month", "4 is not long month"]
# class, message, backtrace が同一のため true になる
p results[0] == results[1] # => true
# class, backtrace が同一だが、message がことなるため false になる
p results[0] == results[2] # => false
//}... -
Range
# ==(other) -> bool (26141.0) -
指定された other が Range クラスのインスタンスであり、 始端と終端が == メソッドで比較して等しく、Range#exclude_end? が同じ場合に true を返します。そうでない場合に false を返します。
...始端と終端が == メソッドで比較して等しく、Range#exclude_end? が同じ場合に
true を返します。そうでない場合に false を返します。
@param other 自身と比較したいオブジェクトを指定します。
//emlist[例][ruby]{
p (1..2) == (1..2)......# => true
p (1..2) == (1...2) # => false
p (1..2) == Range.new(1.0, 2.0) # => true
//}... -
Random
# ==(other) -> bool (26131.0) -
乱数生成器が等しい状態であるならばtrue を返します。
...乱数生成器が等しい状態であるならばtrue を返します。
@param other 比較対象の乱数生成器
//emlist[例][ruby]{
r1 = Random.new(1)
r2 = Random.new(1)
p r1 == r2 # => true
r2.rand
p r1 == r2 # => false
r1.rand
p r1 == r2 # => true
//}... -
Regexp
# ==(other) -> bool (26131.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
//}... -
String
# ==(other) -> bool (26131.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
... == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
stringlike = Object.new
def stringlike.==(other)
"string" ==......other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
BasicObject
# ==(other) -> bool (26125.0) -
オブジェクトが other と等しければ真を、さもなくば偽を返します。
...Person < BasicObject
def initialize(name, age)
@name = name
@age = age
end
end
tanaka1 = Person.new("tanaka", 24)
tanaka2 = Person.new("tanaka", 24)
tanaka1 == tanaka1 #=> true
tanaka1 == tanaka2 #=> false
//}
@see BasicObject#equal?, Object#==, Object#equal?,
Object#eql?... -
Method
# ===(*args) -> object (20207.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...せん。
@param args self に渡される引数。
@see spec/safelevel
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}......f に渡される引数。
@see UnboundMethod#bind_call
@see spec/safelevel
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}......@param args self に渡される引数。
@see UnboundMethod#bind_call
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}... -
Module
# ===(obj) -> bool (20207.0) -
指定された obj が self かそのサブクラスのインスタンスであるとき真を返します。 また、obj が self をインクルードしたクラスかそのサブクラスのインスタンスである場合にも 真を返します。上記のいずれでもない場合に false を返します。
...ではクラス、モジュールの所属関係をチェックすることになります。
//emlist[例][ruby]{
str = String.new
case str
when String # String === str を評価する
p true # => true
end
//}
@param obj 任意のオブジェクト
@see Object#kind_of?, Object#inst... -
String
# ===(other) -> bool (17231.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
... == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
stringlike = Object.new
def stringlike.==(other)
"string" ==......other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?...