るりまサーチ

最速Rubyリファレンスマニュアル検索!
34件ヒット [1-34件を表示] (0.108秒)

別のキーワード

  1. fiddle sym
  2. _builtin to_sym
  3. handle sym
  4. symbol to_sym
  5. string to_sym

ライブラリ

クラス

キーワード

検索結果

NameError#local_variables -> [Symbol] (18214.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] (131.0)

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

...されません。

@param inherit true を指定するとスーパークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。

@see Module.constants, Kernel.#local_variables, Kernel.#global_var...
...nd
class 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
//}...

Object#instance_variables -> [Symbol] (113.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...