るりまサーチ

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

別のキーワード

  1. socket local_creds
  2. socket af_local
  3. socket local_peercred
  4. socket pf_local
  5. socket local_connwait

ライブラリ

クラス

モジュール

検索結果

<< 1 2 > >>

Binding#local_variables -> [Symbol] (18213.0)

ローカル変数の一覧を Symbol の配列で返します。

...カル変数の一覧を Symbol の配列で返します。

//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
//}

このメソッドは以下のコードと同様の動作をします。

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

Kernel.#local_variables -> [Symbol] (18207.0)

現在のスコープで定義されているローカル変数名の配列を返します。

...現在のスコープで定義されているローカル変数名の配列を返します。

//emlist[例][ruby]{
yuyu = 0
p local_variables #=> [:yuyu]
//}

@see Kernel.#global_variables,Object#instance_variables,Module.constants,Module#constants,Module#class_variables...

NameError#local_variables -> [Symbol] (18207.0)

self が発生した時に定義されていたローカル変数名の一覧を返します。

...発生した時に定義されていたローカル変数名の一覧を返します。

内部での使用に限ります。

例:

def foo
begin
b = "bar"
c = 123
d
rescue NameError => err
p err.local_variables #=> [:b, :c, :err]
end
end

a = "buz"
foo...

Module#constants(inherit = true) -> [Symbol] (118.0)

そのモジュール(またはクラス)で定義されている定数名の配列を返します。

...定義された定数が対象にはなります。false を指定した場合 対象にはなりません。

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables

//emlist[Module.constants と Module#constants の違い][ruby]...
...Bar
BAR = 1

# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => []

# ネスト...
...したクラスでは、外側のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constants には含まれる
# (クラス Baz も Bar の定数なので同様)
p Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end
end
//}...

Kernel.#global_variables -> [Symbol] (106.0)

プログラム中で定義されているグローバル変数(`$'で始まる変数)名の 配列を返します。

...グラム中で定義されているグローバル変数(`$'で始まる変数)名の
配列を返します。

//emlist[例][ruby]{
p global_variables #=> [:$;, :$-F, :$@, ... ]
//}

@see Kernel.#local_variables,Object#instance_variables,Module.constants,Module#constants,Module#class_variables...

絞り込み条件を変える

Module#class_variables(inherit = true) -> [Symbol] (106.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...d
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants...

Module.constants -> [Symbol] (106.0)

このメソッドを呼び出した時点で参照可能な定数名の配列を返します。

...//emlist[例][ruby]{
class C
FOO = 1
end
p Module.constants # => [:RUBY_PLATFORM, :STDIN, ..., :C, ...]
# 出力中に :FOO は現われない
//}

@see Module#constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables...

Object#instance_variables -> [Symbol] (106.0)

オブジェクトのインスタンス変数名をシンボルの配列として返します。

...列として返します。

//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables

#=> [:@foo, :@bar]
//}

@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variables...

TracePoint#binding -> Binding (106.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...発生したイベントによって生成された Binding オブジェクトを返します。


//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}...

TracePoint#binding -> Binding | nil (106.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...は binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。

//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}...

絞り込み条件を変える

NEWS for Ruby 2.2.0 (66.0)

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

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

== 2.1.0 以降の変更

=== 言語仕様の変更

* nil/true/false
* nil/true/false はフ...
...セスできないという長年のバグを修正しました。 9593

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

* Binding
* 追加: Binding#local_variables
* 追加: Binding#receiver

* Dir
* 追加: Dir#fileno

* Enumerable
* 追加: Enumerable#slice_after
* 追加: Enumerabl...
...

* GC
* 非互換: GC.stat のエントリーの名前を変更しました 9924
https://docs.google.com/spreadsheets/d/11Ua4uBr6o0k-nORrZLEIIUkHJ9JRzRR0NyZfrhEEnc8/edit?usp=sharing

* Hash
* 非互換: 重複するキーの上書きに関するポリシーを変更しました...
<< 1 2 > >>