Since all you want is a constant, try declaring a submethod that has no
arguments and returns the value, instead, its the same thing. -- Darren Duncan
On 2015-12-17 6:46 PM, TS xx wrote:
Hello dear perl6 users,
I was in the need of declaring a member variable as a constant integer. After
many syntax tryouts I came to this one:
class MyClass {
has int $.myConst;
method new () {
return self.bless();
}
submethod BUILD () {
constant $!myConst = 1;
}
method showMyConst () {
print $!myConst;
}
}
But I'm getting the followinf error message: "Twigil-Variable constants not yet
implemented. Sorry."
The only place in the docs where I have found any reference to constants is in
here: https://doc.perl6.org/language/variables#The_%3F_Twigil
But it's not what I am looking for :/
So my questions are:
Is the syntax right and the thing isn't implemented yet?
Is the syntax (or the full concept) wrong?
Do I have and old interpreter (This is perl6 version 2015.02 built on MoarVM
version 2015.02)?
Thanks to all.
Kind Regards,
Emiliano