That's interesting. I just re-built from github and I'm still
seeing the behavior I reported:
raku -e 'say do given all(3,7) { when Int { "both are Int" };
default {"not similar"} };'
not similar
That's with:
raku --version
Welcome to Rakudo™ v2021.10-43-ga8329f6fd.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2021.10-22-g938098118.
On 11/2/21, Andy Bach <[email protected]> wrote:
>> I'd thought that that would confirm that both elements were Int:
> say do given all(3,7) { when Int { "both are Int" }; default {"not
> similar"} };
> ## not similar
>
> I get a different result
> $ raku -e ' say do given all(3,7) { when Int { "both are Int" }; default
> {"not similar"} };'
> both are Int
>
> $ raku -e ' say do given all(3,"x") { when Int { "both are Int" }; default
> {"not similar"} };'
> not similar
>
> $ raku -e ' say do given all(3,7) { when Int { $_ }; default {"not
> similar"} };'
> all(3, 7)
>
> $ raku -v
> This is Rakudo version 2020.05.1 built on MoarVM version 2020.05
> ________________________________
> From: Joseph Brenner <[email protected]>
> Sent: Tuesday, November 2, 2021 11:45 AM
> To: perl6-users <[email protected]>
> Subject: junctions with given/when
>
> CAUTION - EXTERNAL:
>
>
> A given/when construct using a junction isn't quite doing what I'd expect.
>
> I'd thought that that would confirm that both elements were Int:
>
> say do given all(3,7) { when Int { "both are Int" }; default {"not
> similar"} };
> ## not similar
>
> But this does what I thought it would:
>
> say so do all(3,7) ~~ Int;
> # True
>
> And the given seems to put the junction in $_ as expected:
>
> given all(3,7) { say $_; say $_.WHAT; }
> # all(3, 7)
> # (Junction)
>
> And you can use that junction in a smartmatch explicitly
>
> given all(3,7) { say so $_ ~~ Numeric; }
> # True
> CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary.
> Exercise caution when opening attachments or clicking on links.
>
>