Thanks, both your suggestion and JJ Merelo's work, but I think I like yours for readability:
# # using binding, suggested by JJ Merelo <jjmer...@gmail.com> # my @y := @x but LookInside; # suggested by Elizabeth Mattijsen l...@dijkmat.nl my @y does LookInside = @x; I actually found the use of "but" in the objects docs to be tremendously confusing at first: it looks like some sort of conditional check, like "unless". On Tue, Jun 12, 2018 at 1:01 AM, Elizabeth Mattijsen <l...@dijkmat.nl> wrote: >> On 12 Jun 2018, at 09:06, Joseph Brenner <doom...@gmail.com> wrote: >> >> I thought this would work to make a copy of @x but with the role >> "LookInside" attached to it: >> >> my @y = @x but LookInside; >> >> But that didn't add the role to @y. E.g. >> >> say @y.^WHAT >> >> Would just report (Array), not (Array+{LookInside}). > > What you’re doing here, is assigning the elements of an Array but Lookinside > to a normal Array. The elements of the Array do not have any roles mixed in, > so you wind up with a normal Array with normal elements in them. Perhaps you > meant: > > my @y does LookInside = @x; > > Here you create an Array @y with the role LookInside mixed in, and *then* > assign the values from @x. > > > > Also, what JJ Merelo said: StackOverflow is your friend :-) > > > > Liz