るりまサーチ

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

別のキーワード

  1. win32ole win32ole_variable
  2. win32ole_variable to_s
  3. win32ole_variable name
  4. thread thread_variable?
  5. win32ole_variable value

検索結果

<< < 1 2 3 4 ... > >>

Module#class_variable_defined?(name) -> bool (6126.0)

name で与えられた名前のクラス変数がモジュールに存在する場合 true を 返します。

...name Symbol か String を指定します。

//emlist[例][ruby]{
class Fred
@@foo = 99
end
Fred.class_variable_defined?(:@@foo) #=> true
Fred.class_variable_defined?(:@@bar) #=> false
Fred.class_variable_defined?('@@foo') #=> true
Fred.class_variable_defined?('@@bar') #=> false
//}...

Object#remove_instance_variable(name) -> object (6126.0)

オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。

...ない場合に発生します。

//emlist[][ruby]{
class Foo
def foo
@foo = 1
p remove_instance_variable(:@foo) #=> 1
p remove_instance_variable(:@foo) # instance variable @foo not defined (NameError)
end
end
Foo.new.foo
//}

@see Module#remove_class_variable,Module#remove_const...

Thread#thread_variable?(key) -> bool (6126.0)

引数 key で指定した名前のスレッドローカル変数が存在する場合に true、そ うでない場合に false を返します。

...thread_variable_set(:oliver, "a")
me.thread_variable?(:oliver) # => true
me.thread_variable?(:stanley) # => false

[注意]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)が
対象ではない事に注意してください。

@see Thread#thread_variable_get, T...

Thread#thread_variable_get(key) -> object | nil (6126.0)

引数 key で指定した名前のスレッドローカル変数を返します。

...例:

Thread.new {
Thread.current.thread_variable_set("foo", "bar") # スレッドローカル
Thread.current["foo"] = "bar" # Fiber ローカル

Fiber.new {
Fiber.yield [
Thread.current.thread_variable_get("foo"), # スレッドローカル...
...]
}.resume
}.join.value # => ['bar', nil]

この例の "bar" は Thread#thread_variable_get により得られ
た値で、nil はThread#[] により得られた値です。

@see Thread#thread_variable_set, Thread#[]

@see https://magazine.rubyist.net/articles/0041/0041-200Special-note.h...

Module#remove_class_variable(name) -> object (6120.0)

引数で指定したクラス変数を取り除き、そのクラス変数に設定さ れていた値を返します。

...ールやクラスに定義されていない場合に発生します。

//emlist[例][ruby]{
class Foo
@@foo = 1
remove_class_variable(:@@foo) # => 1
p @@foo # => uninitialized class variable @@foo in Foo (NameError)
end
//}

@see Module#remove_const, Object#remove_instance_variable...

絞り込み条件を変える

Thread#thread_variable_set(key, value) (6120.0)

引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま す。

...

//emlist[例][ruby]{
thr = Thread.new do
Thread.current.thread_variable_set(:cat, 'meow')
Thread.current.thread_variable_set("dog", 'woof')
end
thr.join # => #<Thread:0x401b3f10 dead>
thr.thread_variables # => [:dog, :cat]
//}

@see Thread#thread_variable_get, Thread#[]...

Module#class_variable_get(name) -> object (6108.0)

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

...の値を返します。

@param name String または Symbol を指定します。

@raise NameError クラス変数 name が定義されていない場合、発生します。

//emlist[例][ruby]{
class Fred
@@foo = 99
end

def Fred.foo
class_variable_get(:@@foo)
end

p Fred.foo #=> 99
//}...

Module#class_variable_set(name, val) -> object (6108.0)

クラス/モジュールにクラス変数 name を定義して、その値として val をセットします。val を返します。

...をセットします。val を返します。

@param name String または Symbol を指定します。

//emlist[例][ruby]{
class Fred
@@foo = 99
def foo
@@foo
end
end

def Fred.foo(val)
class_variable_set(:@@foo, val)
end

p Fred.foo(101) # => 101
p Fred.new.foo # => 101
//}...

Object#instance_variables -> [Symbol] (6107.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...
<< < 1 2 3 4 ... > >>