Juerd asked:
>> 2+ args: interpolate specified operator
>> 1 arg: return that arg
>> 0 args: fail (i.e. thrown or unthrown exception depending on use fatal)
>
> Following this logic, does join(" ", @foo) with +@foo being 0 fail too?
No. It returns empty string. You could think of C<join> as being implemented:
sub join (Str $sep, *@list) { reduce { $^a ~ $sep ~ $^b } "", @list }
Just as C<sum> is probably implemented:
sub sum (*@list) { [+] 0, @list }
> I dislike this, and would prefer [op] with no elements to simply return
> whatever () returns: an empty list in list context, undef in scalar
> context.
I'd have assumed that "empty list in list context, undef in scalar
context" *is* what C<fail> returns when C<use fatal> isn't in effect.
Damian
Thread Previous
|
Thread Next