るりまサーチ

最速Rubyリファレンスマニュアル検索!
944件ヒット [1-100件を表示] (0.099秒)

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object to_enum
  5. object enum_for

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Object#==(other) -> bool (27249.0)

オブジェクトと other が等しければ真を返します。

...o = Object.new
p(o.eql?(o)) #=> true
p(o.eql?(Object.new)) #=> false
//}

下記の例のように、各クラスの性質に合わせて再定義されることが期待されています。

//emlist[適切に再定義されている例][ruby]{
p("foo" == "bar") #=> false
p("foo" == "foo") #=> tr...
...ue

p(4 == 4) #=> true
p(4 == 4.0) #=> true
//}

@see Object#equal?,Object#eql?...

Object#===(other) -> bool (21319.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

... Object#== を呼び出します。

when 節の式をレシーバーとして === を呼び出すことに注意してください。

また Enumerable#grep でも使用されます。

@param other 比較するオブジェクトです。

//emlist[][ruby]{
age = 12
# (0..2).===(12), (3..6).===(12...
...ult"
end

puts result #=> "child"

def check arg
case arg
when /ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end

puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class....
...But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's world>
//}

@see Object#==, Range#===, Module#===, Regexp#===, Enumerable#grep...

BasicObject#==(other) -> bool (21237.0)

オブジェクトが other と等しければ真を、さもなくば偽を返します。

...デフォルトでは Object#equal? と同じオブジェクトの同一性になっています。

@param other 比較対象となるオブジェクト
@return other が self と同値であれば真、さもなくば偽

//emlist[例][ruby]{
class 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?...

DRb::DRbObject#==(other) -> bool (21201.0)

DRb::DRbObject オブジェクト同士が同じであるなら真を返します。

...DRb::DRbObject オブジェクト同士が同じであるなら真を返します。

この同値判定は、
オブジェクトが参照している URI と識別子が等しいかどうかでします。...

Array#==(other) -> bool (18241.0)

自身と other の各要素をそれぞれ順に == で比較し て、全要素が等しければ true を返します。そうでない場合には false を返します。

... == で比較し
て、全要素が等しければ true を返します。そうでない場合には false を返します。

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

@see Object#==

//emlist[例][ruby]{
[ "a", "c" ] == [ "a", "c", 7 ] #=> false
[ "a", "c", 7 ] == [...
..."a", "c", 7 ] #=> true
[ "a", "c", 7 ] == [ "a", "d", "f" ] #=> false
//}...

絞り込み条件を変える

Data#==(other) -> bool (18235.0)

self と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。

...self と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に
true を返します。そうでない場合に false を返します。

@param other self と比較したいオブジェクトを指定します。

//emlist[例][ruby]{
Dog = Data.def...
...e(:name, :age)
dog1 = Dog.new("Fred", 5)
dog2 = Dog.new("Fred", 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?...

String#==(other) -> bool (18231.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?...

Set#==(set) -> bool (18219.0)

2 つの集合が等しいときに true を返します。

...を返します。
要素の等しさは Object#eql? により判定されます。

@param set 比較対象のオブジェクトを指定します。

//emlist[][ruby]{
require 'set'
s1 = Set[10, 20, 30]
s2 = Set[10, 30, 40]
s3 = Set[30, 10, 30, 20]
p s1 == s2 # => false
p s1 == s3 # => true
//}...
...には、false を返します。
要素の等しさは Object#eql? により判定されます。

@param set 比較対象のオブジェクトを指定します。

//emlist[][ruby]{
s1 = Set[10, 20, 30]
s2 = Set[10, 30, 40]
s3 = Set[30, 10, 30, 20]
p s1 == s2 # => false
p s1 == s3 # => true
//}...

Method#===(*args) -> object (12411.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 (12313.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#instance_of?, d:spec/control#case...

絞り込み条件を変える

<< 1 2 3 ... > >>