On 9/26/18 7:01 PM, Curt Tilmes wrote:

    And where is it stated that an empty () defaults to all of them
    and not to none of them?


empty() says set everything to defaults

If you have
sub foo($x = 3) { say $x }

and call foo(2), $x will be set to 2 and it will print out 2.

If you don't pass in $x, saying just foo()  or even just foo by itself, it is exactly the same
as saying foo(3).  You just get the default and it prints 3.

foo(3)
foo()
foo

are all the same.

If I have  sub foo($x = Inf) (say $x)
I'm just making the default parameter Inf instead of 3

     And where is it stated that an empty () defaults to all of them
     and not to none of them?

It tells you right in the signature what the default is.  It says "$limit = Inf", Inf is an infinite number of words, i.e. all of them.  If it said "$limit = 0", then the default would
be 0, or none of them.  That isn't what it states.

words(Inf)
words()
words

are all the same.

Curt


Beautifully written.  Thank you Curt.

Reply via email to