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;
}
}
Question
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:
Solution
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;
}
}