質問

What is the correct implementation of singleton pattern in perl6?

I've tried this but I dont' know how to use static keyword in perl6:

役に立ちましたか?

解決

It one of the few reasons that require using bless method

class Singleton {
    my Singleton $instance;
    method new {!!!}
    submethod instance {
        $instance = Singleton.bless unless $instance;
        $instance;
    }
 }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top