An empty Array is falsey, yet an empty shaped Array is truthy
I will hazard a guess that Raku handles arrays in scalar context similarly to Perl 5: an array evaluated in scalar context produces the number of elements in the array. An empty array has zero elements, but a shaped array has a fixed number of elements. In boolean context, zero is false and any non-zero number is true.
Thus, an empty array (with zero elements) is a false value, but an array with a fixed non-zero number of elements is a true value.
In reply to Re^5: [Raku] Assigning defaults to attributes that are fixed length lists (and other confusions)
by jcb
in thread [Raku] Assigning defaults to attributes that are fixed length lists (and other confusions)
by tomgracey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |