るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< < 1 2 >>

Object#instance_variable_defined?(var) -> bool (44.0)

インスタンス変数 var が定義されていたら真を返します。

...す。

@
param var インスタンス変数名を文字列か Symbol で指定します。

//emlist[][ruby]{
class Fred
def initialize(p1, p2)
@
a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
p fred.instance_variable_defined?(:@a) #=> true
p fred.instance_variable_defined?("@b") #=>...
...true
p fred.instance_variable_defined?("@c") #=> false
//}

@
see Object#instance_variable_get,Object#instance_variable_set,Object#instance_variables...

Object#instance_variable_get(var) -> object | nil (38.0)

オブジェクトのインスタンス変数の値を取得して返します。

...

@
param var インスタンス変数名を文字列か Symbol で指定します。

//emlist[][ruby]{
class Foo
def initialize
@
foo = 1
end
end

obj = Foo.new
p obj.instance_variable_get("@foo") #=> 1
p obj.instance_variable_get(:@foo) #=> 1
p obj.instance_variable_get(:@bar)...
...#=> nil
//}

@
see Object#instance_variable_set,Object#instance_variables,Object#instance_variable_defined?...

Object#to_s -> String (32.0)

オブジェクトの文字列表現を返します。

...使って文字列に変換し
ます。

//emlist[][ruby]{
class Foo
def initialize num
@
num = num
end
end
it = Foo.new(40)

puts it #=> #<Foo:0x2b69110>

class Foo
def to_s
"Class:Foo Number:#{@num}"
end
end

puts it #=> Class:Foo Number:40
//}

@
see Object#to_str,Kernel.#String...
<< < 1 2 >>