El Sunday, 03 de March del 2019 a les 02:09, ToddAndMargo via perl6-users va 
escriure:

I want to pass an integer to a sub.  The only
valid values of the integer are 1, 2, 4, 8, and 16.

Other than using "if" to test their values, is
there a way to state that an integer can only
have certain predefined values?

I like this syntax:
sub MAIN(Int $value where $value ∈ <1 2 4 8 16 >) {
....
}

It is readable and I really like to use the '∈' symbol :D.

Cheers!
--
(≧∇≦) Mimosinnet (Linux User: #463211)

Reply via email to