I imagine P6 may one day be changed to do as you suggest. But for now I think something like this is the closest you'll get:
subset Str_Int of List where Str, Int; sub foo (--> Str_Int) { return 'a', 42 } -- raiph On Fri, Oct 12, 2018 at 11:23 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > On 10/12/18 2:35 PM, Curt Tilmes wrote: > > > > > > On Fri, Oct 12, 2018 at 5:08 PM ToddAndMargo via perl6-users > > <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote: > > > > >> On 10/12/18 12:52 PM, Curt Tilmes wrote: > > >> > You could make a subset for the List your're trying to > > return: > > >> > > > >> > subset liststrint of List where .[0] ~~ Str && .[1] ~~ > Int; > > >> > sub RtnOrd( Str $Char --> liststrint) ... > > >> > > >> I am confused. > > >> > > >> I want to get the --> syntax correct for `return $Char, > > ord($Char)` > > > > On 10/12/18 1:49 PM, Brad Gilbert wrote: > > > That would be `List` > > > > > > sub RtnOrd( Str $Char --> List ){ $Char, ord($Char) } > > > say RtnOrd "A" > > > # (A 65) > > > > $ p6 'sub RtnOrd( Str $Char --> List ){return $Char, ord($Char)}; say > > RtnOrd "A";' > > (A 65) > > > > But "List" does not tell my what is in the list. > > > > > > You can create a brand new type, a subset of Lists where the first > element > > (we refer to with [0]) is of type Str (~~ Str) and the second element of > > the List > > (we refer to with [1]) is of type Int (~~ Int). > > > > Define it like this: > > subset list-str-int of List where .[0] ~~ Str && .[1] ~~ Int; > > > > then you can say that your routine returns a list that looks like that: > > > > sub RtnOrd( Str $Char --> list-str-int) > > > > Is there any way to say I am return two things: a string and an integer? >