Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^5: [Raku] Assigning defaults to attributes that are fixed length lists (and other confusions)

by jcb (Parson)
on May 05, 2021 at 21:33 UTC ( [id://11132112]=note: print w/replies, xml ) Need Help??


in reply to Re^4: [Raku] Assigning defaults to attributes that are fixed length lists (and other confusions)
in thread [Raku] Assigning defaults to attributes that are fixed length lists (and other confusions)

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.

  • Comment on Re^5: [Raku] Assigning defaults to attributes that are fixed length lists (and other confusions)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132112]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-18 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found