You're wrong in your expectations. Smartmatch as such is implemented by ACCEPTS 
method of its RHS. It is Junction.ACCEPTS in our case. Unfortunately, the 
method is not documented for Junction, but it considers itself a boolean 
context and, correspondingly, collapses the junction.

Not it is true with eq which is a normal routine and Raku autothreads over it. 
It still works well in conditions because they're boolean context and collapse 
the resulting junction.

Best regards,
Vadim Belman

> On May 23, 2021, at 4:14 PM, Joseph Brenner <doom...@gmail.com> wrote:
> 
> Junctions continue to surprise me:
> 
>    my $junction = any( 'a', 'b', 'c' );
>    my $char = 'b';
>    say $char ~~ $junction; # True
>    say $char eq $junction; # any(False, True, False)
> 
>    $char = 'e';
>    say $char ~~ $junction; # False
>    say $char eq $junction; # any(False, False, False)
> 
> I would've thought that there'd be no difference there
> The smartmatch checks that it's comparing string types,
> and does something like an eq on them, right?
> So why would going straight to an eq be different?
> 
> But then, there are other cases where junction-in,
> junction-out is the only thing that makes sense:
> 
>    say $junction ~ 'z';
>    # any(az, bz, cz)
> 

Reply via email to