Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between $?CLASS and ::?CLASS

The Raku docs describe ::?CLASS as a compile-time variable that answers "Which class am I in?". Then, a couple of paragraphs later, it mentions $?CLASS, and says that it answers "Which class am I in? (as variable)".

What's the difference between these two variables? They often seem to contain the same value – do they always? Or are there differences I haven't observed?

like image 758
codesections Avatar asked Jun 24 '26 02:06

codesections


1 Answers

These two forms of compile-time variables are different syntactically.

The syntactic form ::?foo may be used as, and will be evaluated as:

  • A term (just like a variable such as $?foo).

  • A type constraint (unlike a variable such as $?foo).

like image 79
raiph Avatar answered Jun 27 '26 02:06

raiph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!