Re: Can methods have multiple inputs?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 07:48 PM, Brad Gilbert wrote:

On Fri, Sep 14, 2018 at 6:03 PM ToddAndMargo  wrote:



On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo mailto:toddandma...@zoho.com>> wrote:

 Hi All,

 Can a method be given multiple inputs?

   ( $a, $b ).foo

 and how would the docs write it?

   method foo(Any:D Any:D:  -->Bool)

 Is there a comma or a space between the two "any"'s?

 Many thanks,
 -T





On 09/14/2018 03:52 PM, Brandon Allbery wrote:

In that case, you're not giving it two items; you are giving it a single
List that happens to have two items within it. A method has one
invocant. If you are invoking method foo on that, its invocant is a List.

  > my $a; my $b; say ($a, $b).^name
List


Makes sense.  () turns it into a "List" so it
can be passed as one.

Thank you!


No () doesn't turn it into a list.

The comma turns it into a list

The () just act as a way to textually encapsulate the list

 (42).^name;  # Int
 (42, ).^name; # List

This is a very important distinction.

 [[[42]]].perl(); # [42]
 [[[42],],].perl(); # [[[42],],]

 (((42))).perl(); # 42
 (((42,),),).perl(); # (((42,),),)



Thank you!

--

Yesterday it worked.
Today it is not working.
Windows is like that.



Re: Can methods have multiple inputs?

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 6:03 PM ToddAndMargo  wrote:
>
> >> On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo  >> > wrote:
> >>
> >> Hi All,
> >>
> >> Can a method be given multiple inputs?
> >>
> >>   ( $a, $b ).foo
> >>
> >> and how would the docs write it?
> >>
> >>   method foo(Any:D Any:D:  -->Bool)
> >>
> >> Is there a comma or a space between the two "any"'s?
> >>
> >> Many thanks,
> >> -T
> >>
>
>
>
> On 09/14/2018 03:52 PM, Brandon Allbery wrote:
> > In that case, you're not giving it two items; you are giving it a single
> > List that happens to have two items within it. A method has one
> > invocant. If you are invoking method foo on that, its invocant is a List.
> >
> >  > my $a; my $b; say ($a, $b).^name
> > List
>
> Makes sense.  () turns it into a "List" so it
> can be passed as one.
>
> Thank you!

No () doesn't turn it into a list.

The comma turns it into a list

The () just act as a way to textually encapsulate the list

(42).^name;  # Int
(42, ).^name; # List

This is a very important distinction.

[[[42]]].perl(); # [42]
[[[42],],].perl(); # [[[42],],]

(((42))).perl(); # 42
(((42,),),).perl(); # (((42,),),)


Re: Can methods have multiple inputs?

2018-09-14 Thread ToddAndMargo
On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo > wrote:


Hi All,

Can a method be given multiple inputs?

  ( $a, $b ).foo

and how would the docs write it?

  method foo(Any:D Any:D:  -->Bool)

Is there a comma or a space between the two "any"'s?

Many thanks,
-T





On 09/14/2018 03:52 PM, Brandon Allbery wrote:
In that case, you're not giving it two items; you are giving it a single 
List that happens to have two items within it. A method has one 
invocant. If you are invoking method foo on that, its invocant is a List.


 > my $a; my $b; say ($a, $b).^name
List


Makes sense.  () turns it into a "List" so it
can be passed as one.

Thank you!


Re: Can methods have multiple inputs?

2018-09-14 Thread Brandon Allbery
In that case, you're not giving it two items; you are giving it a single
List that happens to have two items within it. A method has one invocant.
If you are invoking method foo on that, its invocant is a List.

> my $a; my $b; say ($a, $b).^name
List


On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo  wrote:

> Hi All,
>
> Can a method be given multiple inputs?
>
>  ( $a, $b ).foo
>
> and how would the docs write it?
>
>  method foo(Any:D Any:D:  -->Bool)
>
> Is there a comma or a space between the two "any"'s?
>
> Many thanks,
> -T
>


-- 
brandon s allbery kf8nh
allber...@gmail.com