I think it's best that I show you examples from the official documentation.
Let's use chdir as our example.

https://docs.raku.org/routine/chdir

chdir has the following signature:

sub chdir(IO() $path, :$d = True, :$r, :$w, :$x --> IO::Path:D)


So let's break this down.

$path :: This is a positional parameter.  You know it's positional because
of a lack of preceding colon (:)
:$d :: This is a named parameter w/ a default value of True
:$r :: This is a named parameter
:$w :: This is a named parameter
:$x :: This is a named parameter

So let''s try it!

# Just the positional parameter
chdir('/tmp');

# Both positional and named parameter ':d' set to False
chdir('/tmp', :d(False));

# Again, both positional and named, but this time with named parameters
':d' set to False and ':x' set to True.  ':x' is enough to set to True ..
you can alternatively do a ':x(True)'.
chdir('/tmp', :d(False), :x;

# Same as last one, though named parameter order doesn't matter.
chdir('/tmp', :x, :d(False));

Now quickly imagine you had a variable set to False like the following:

my $d = False;

I could instead have written the above examples like the following (in the
order the above was written):

chdir('/tmp');
chdir('/tmp', :$d);
chdir('/tmp', :$d, :x);
chdir('/tmp', :x, :$d);


If you desire another example, please let me know.  I believe given your
latest comment and this latest example, that would be enough.
If not, I'll happily provide another one.

~Paul

On Sun, Feb 9, 2020 at 5:20 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-02-08 15:39, Paul Procacci wrote:
> > sub a(:$a, :$b, :$c) {}
> >
> > a(:c(1), :a(0), :b(3));
>
> Hi Paul,
>
> I think I got it, but would yo give me one more exampale
> to make sure I fully understand?
>
> sub a(:$a, :$b, :$c) {}
>
> a(:c(1), :a(0), :b(3));
>
> But with two that are not named and two that are named.
> And what is the order?
>
>
> Many thanks,
> -T
>


-- 
__________________

:(){ :|:& };:

Reply via email to