るりまサーチ

最速Rubyリファレンスマニュアル検索!
47件ヒット [1-47件を表示] (0.087秒)
トップページ > クエリ:Ruby[x] > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:-[x] > クエリ:b[x] > クエリ:end[x] > クエリ:local_variables[x]

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

Binding#local_variables -> [Symbol] (24350.0)

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

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

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

end

//}

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

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

TracePoint#binding -> Binding (6331.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 (6331.0)

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

...生成された Binding オブジェクトを返します。

C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。

//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePo...
...int.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end

trace.enable
foo 1
//}...

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

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

...[例][ruby]{
class One
@@var1 = 1
end

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(inherit = true) -> [Symbol] (249.0)

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

...クルードしているモジュールの定数も含みます。
Object のサブクラスの場合、Objectやそのスーパークラスで定義されている
定数は含まれません。 Object.constants とすると Object クラスで定義された
定数の配列が得られます。...
....#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables

//emlist[Module.constants と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.constants

class Foo
FOO = 1
end

c...
...lass Bar
B
AR = 1

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

# ネ...

絞り込み条件を変える