前田です。 In message "[ruby-list:6124] Re: Ruby 連載 第 3 回" Yukihiro Matsumoto <matz / netlab.co.jp> wrote: |まだ,作っていませんがSingletonパターン(あるクラスのインスタ |ンスを一つだけしか生成しないパターン)もライブラリ化できるは |ずです. 単純なのでよければ、 module Singleton def Singleton.append_features(klass) klass.private_class_method(:new) klass.instance_eval %{ def instance if defined?(@__instance__) return @__instance__ else return @__instance__ = new end end } end end みたいにすぐ書けますね。 -- 前田 修吾