Still ugly but much more reliable trick would be to use a sub and a counter 
variable:

my atomicint $c = 0;
sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
say $c;

Or, taking about tricks:

('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });

Apparently, this one is not ugly by semantics, but by its notation too. Also 
worth noting that the hyper-op is needed here because pointy blocks are not 
auto-threaded over junctions and take them as-is:

-> $v { say $v.WHAT }(1|2); # (Junction)

Best regards,
Vadim Belman

> On May 24, 2021, at 8:42 AM, Daniel Sockwell <dan...@codesections.com> wrote:
> 
>> It can be done without the EVAL:
>> 
>>> any('a', 'b', 'c').raku.substr(4, *-1).split(',').elems
>> 
>> 3
> 
> Yeah, but only at the cost of some fragility:
> 
>> any('a', 'b,b', 'c').raku.substr(4, *-1).split(',').elems
> 4
> 
> I suppose you could do:
> 
>> any('a', 'b,b', 'c').elems.raku.substr(4, *-1).split(',').elems
> 3
> 
> but I'm not sure that's _that_ much better than EVAL – either way, we're 
> depending on the Str
> representation of inherently non-Str data, which seems like the main sin of 
> EVAL.
> 
> – codesections
> 

Reply via email to