On Tue, 5 Mar 2019 at 01:23, Brad Gilbert wrote:
>
> Somewhere on the Internet I layed out the rules that I think that
> should normally be followed, but I am not sure where.
>
Perhaps:
https://stackoverflow.com/questions/54338491/string-matching-in-main-parameters
--
Norman Gaywood, Compute
On Mon, Mar 4, 2019 at 8:22 AM Brad Gilbert wrote:
...
> Somewhere on the Internet I layed out the rules that I think that
> should normally be followed, but I am not sure where.
...
It would be nice to find it and add to the docs.
-Tom
An Array isn't a type of Str.
@ ~~ Str; # False
Array ~~ Str; # False
You can have an array that has a type constraint.
(my Str @) ~~ Array[Str]; # True
(my @ of Str) ~~ Array[Str]; # True
Or you could check that all of the values of the Array are of some type.
(my @ = ) ~~
Hi Brad,
How far should I follow the rule that I should not use a smartmatch in a
where clause?
I'm thinking of this:
> sub test1(:@array? where Str) { say 'ok' }
&test1
> test1()
Constraint type check failed in binding to parameter '@array'; expected
anonymous constraint to be met but got Array
On 3/3/19 8:29 PM, Brad Gilbert wrote:
It should be
sub mysub(Int $value where 1|2|4|8|16)
{
say "Got $value"
}
:-)