Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

invert needs a Pair?

Tags:

raku

The invert method for Lists should return the inverted sequence, or at least that's what the source seems to imply. However:

say (1,3,2).invert 

fails with:

(exit code 1) Type check failed in invert; expected Pair but got Int (1)␤  in block <unit>

The documentation does not help, because it's LTA in this area (and missing for List). But the source code does not admit any ambiguous interpretation. Is there anything I'm missing here?

like image 846
jjmerelo Avatar asked Feb 18 '19 18:02

jjmerelo


1 Answers

Perhaps you intended to use the reverse method. Well, if you want the result to be (2,3,1).

It looks like the documentation of List.invert is indeed missing. It is intended to work only on a List that consists of Pairs. I'll write that up now.

EDIT: doc added with https://github.com/perl6/doc/commit/0ee3245776

like image 77
Elizabeth Mattijsen Avatar answered Oct 01 '22 12:10

Elizabeth Mattijsen