るりまサーチ (Ruby 3.3)

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

別のキーワード

  1. handle_interrupt thread#raise
  2. add rexml::attribute#name
  3. << rexml::attribute#name
  4. simplerenewer rinda::tuplespace#renewer
  5. inspect? irb::context#inspect_mode

検索結果

Singleton (97.0)

Singleton パターンを提供するモジュールです。

...Singleton パターンを提供するモジュールです。

Mix-in により singleton パターンを提供します。

Singleton
モジュールを include することにより、クラスは
高々ひとつのインスタンスしか持たないことが保証されます。

Singleton
を M...
...ire 'singleton'

class SomeSingletonClass
include Singleton
#....
end

a = SomeSingletonClass.instance
b = SomeSingletonClass.instance # a and b are same object
p [a,b] # => [#<SomeSingletonClass:0x0000562e6e18ddd0>, #<SomeSingletonClass:0x0000562e6e18ddd0>]
a = SomeSingletonClass...
....new # => NoMethodError (private method `new' called for SomeSingletonClass:Class)...