るりまサーチ

最速Rubyリファレンスマニュアル検索!
44件ヒット [1-44件を表示] (0.135秒)
トップページ > クエリ:i[x] > クエリ:Variable[x] > クエリ:local_variable_get[x]

別のキーワード

  1. win32ole win32ole_variable
  2. _builtin local_variable_get
  3. binding local_variable_get
  4. binding local_variable_set
  5. _builtin local_variable_set

ライブラリ

クラス

検索結果

Binding#local_variable_get(symbol) -> object (33338.0)

引数 symbol で指定した名前のローカル変数に設定された値を返します。

...オブジェクトで指定します。

@raise NameError 引数 symbol で指定したローカル変数が未定義の場合に発生します。

//emlist[例][ruby]{
def foo
a = 1
binding.local_variable_get(:a) # => 1
binding.local_variable_get(:b) # => NameError
end
//}

このメソッ...
...ドは以下のコードの短縮形です。

//emlist[][ruby]{
binding.eval("#{symbol}")
//}

@see Binding#local_variable_set, Binding#local_variable_defined?...

Binding#local_variable_defined?(symbol) -> bool (18237.0)

引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。

...//emlist[例][ruby]{
def foo
a = 1
binding.local_variable_defined?(:a) # => true
binding.local_variable_defined?(:b) # => false
end
//}

このメソッドは以下のコードの短縮形です。

//emlist[][ruby]{
binding.eval("defined?(#{symbol}) == 'local-variable'")
//}

@see Binding#lo...
...cal_variable_get, Binding#local_variable_set...

Binding#local_variable_set(symbol, obj) (15267.0)

引数 symbol で指定した名前のローカル変数に引数 obj を設定します。

...//emlist[例][ruby]{
def foo
a = 1
bind = binding
bind.local_variable_set(:a, 2) # set existing local variable `a'
bind.local_variable_set(:b, 3) # create new local variable `b'
# `b' exists only in binding
p bind.local_variable_get(:a) # => 2
p bind.lo...
...cal_variable_get(:b) # => 3
p a # => 2
p b # => NameError
end
//}

このメソッドは以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。

//emlist[][ruby]{
binding.eval("#{sy...
...mbol} = #{obj}")
//}

@see Binding#local_variable_get, Binding#local_variable_defined?...

NEWS for Ruby 2.1.0 (54.0)

NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。

== 2.0.0 以降の変更

=== 言語仕様の変更

* キーワード引数のデフォルト値が省略可...
...nil の代わりにメソッド名をシンボルで返します

=== 組み込みクラスの更新

* Array
* 追加: Array#to_h キーと値のペアの配列をハッシュに変換します。

* Binding
* 追加: Binding#local_variable_get
* 追加: Binding#local_variable_set...
...追加: Binding#local_variable_defined?

* Enumerable
* 追加: Enumerable#to_h キーと値のペアのリストをハッシュに変換します。

* Exception
* 追加: Exception#cause 一つ前の例外を新しい例外を返します。
例外を rescue して raise しな...