The correct way to do this is any(5,"flarg") ~~ 5. ~~ is very tolerant. I
think it's generally considered a bug anytime ~~ throws an exception
because of invalid LHS. IMO any() junctions should propagate exceptions
regardless of whether one of its other values succeeded.
I tried to think of how I could use a particular comparison operator with a
junction and have it not throw exceptions but it didn't work:
any(5,"flarg") ~~ { try $_ == 5 }
I guess bare blocks don't autothread because $_ is Mu, but I would have
thought ACCEPTS on Code would autothread but it seems it's also Mu (could
we change this?).
The best I can do is the rather hairy:
say so any(5,"flarg") ~~ -> Any $_ { try $_ == 5 }
which also throws some "useless use of" exception for some reason :\
LL
On Sat, Apr 8, 2017 at 3:28 AM Zoffix Znet via RT <
[email protected]> wrote:
And if you just give a Failure into a Junction it doesn't explode it and
propagates it:
m: say so any("flarg",42)».Numeric
rakudo-moar 15a25d: OUTPUT: «True»
m: say sub ($_) { .^name }( +any("flarg",42) )
rakudo-moar 15a25d: OUTPUT: «any(Failure, Int)»
Wonder if there's a way to make it handle exceptions too somehow. A sort of
Junctionized `try` block