るりまサーチ

最速Rubyリファレンスマニュアル検索!
168件ヒット [101-168件を表示] (0.126秒)
トップページ > クエリ:Ruby[x] > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:i[x] > クエリ:@[x] > クラス:BasicObject[x]

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

検索結果

<< < 1 2 >>

BasicObject#! -> bool (3056.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

...lf が nil または false であれば真を、さもなくば偽を返します。
主に論理式の評価に伴って副作用を引き起こすことを目的に
再定義するものと想定されています。

このメソッドを再定義しても Ruby の制御式において nil や fa...
...とはありません。

@
return オブジェクトが偽であれば真、さもなくば偽

//emlist[例][ruby]{
class NegationRecorder < BasicObject
def initialize
@
count = 0
end
attr_reader :count

def !
@
count += 1
super
end
end

recorder = NegationRecorder.new
!recorde...
...r
!!!!!!!recorder
puts 'hoge' if !recorder

puts recorder.count #=> 3
//}

//emlist[例][ruby]{
class AnotherFalse < BasicObject
def !
true
end
end
another_false = AnotherFalse.new

# another_falseは*真*
puts "another false is a truth" if another_false
#=> "another false is a truth"
//}...

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

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

...トの同一性になっています。

@
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?...

BasicObject#!=(other) -> bool (3038.0)

オブジェクトが other と等しくないことを判定します。

...論理否定して返します。
このため、サブクラスで BasicObject#== を再定義しても != とは自動的に整合性が
とれるようになっています。

ただし、 BasicObject#!= 自身や BasicObject#! を再定義した際には、ユーザーの責任で
整合性を...
...す。

@
param other 比較対象となるオブジェクト
@
see BasicObject#==, BasicObject#!

//emlist[例][ruby]{
class NonequalityRecorder < BasicObject
def initialize
@
count = 0
end
attr_reader :count

def !=(other)
@
count += 1
super
end
end
recorder = NonequalityRecorder...
....new

recorder != 1
puts 'hoge' if recorder != "str"

p recorder.count #=> 2
//}...

BasicObject#__send__(name, *args) -> object (3032.0)

オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。

...す。

@
param name 呼び出すメソッドの名前。 Symbol または文字列で指定します。
@
param args メソッドに渡す任意個の引数

//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#sen...
...d) - #{name} #{args.join(',')}"
end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__send__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}

@
see Object#send...

BasicObject#__send__(name, *args) { .... } -> object (3032.0)

オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。

...す。

@
param name 呼び出すメソッドの名前。 Symbol または文字列で指定します。
@
param args メソッドに渡す任意個の引数

//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#sen...
...d) - #{name} #{args.join(',')}"
end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__send__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}

@
see Object#send...

絞り込み条件を変える

BasicObject#equal?(other) -> bool (3032.0)

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

...
ただし、 BasicObject の位置づけ上、どうしても再定義が必要な用途もあるでしょう。
再定義する際には自分が何をしているのかよく理解してから実行してください。

@
param other 比較対象となるオブジェクト
@
return other が se...
...ば真、さもなくば偽

//emlist[例][ruby]{
original = "a"
copied = original.dup
substituted = original

original == copied #=> true
original == substituted #=> true
original.equal? copied #=> false
original.equal? substituted #=> true
//}

@
see Object#equal?, Object#==, Obje...
<< < 1 2 >>