Thanks Liz, I will stick with the method aproach.
Regards, Emiliano > Subject: Re: Constants as members of a class > From: l...@dijkmat.nl > Date: Fri, 18 Dec 2015 23:49:53 +0100 > To: perl6-users@perl.org > > > On 18 Dec 2015, at 23:37, TS xx <maringa...@hotmail.com> wrote: > > > > Hi Liz, thanks for your reply. > > > > Can I call the method from static context? > > I mean: MyClass.FOO > > In general, yes: > > class A { > method FOO { 42 } # note the method doesn’t reference any attributes > } > say A.FOO; > say A.new.FOO; # also works on instances > > You can even have a method to be called in case of a static (class) context, > and one to be called in the case of an instance: > > class B { > has $.FOO = 666; > multi method FOO(B:U:) { 42 } # B is the class, :U is undefined, > final : for self > multi method FOO(B:D:) { $!FOO } # :D is defined, > } > say B.FOO; # 42 > say B.new.FOO; # 666 > say B.new(FOO => 3.14).FOO; # 3.14 > > > Hope this helps! > > > > Liz