Returning a 'raw' scalar container from AT-POS method (rather than a Proxy instance) in a class that 'does' Positional?
问题 I'm attempting to implement a class that 'does' Positional that also allows me to update its values by assigning to the result returned by the AT-POS method. Eventually, I was able to concoct the following class that works as intended: class Test does Positional { has $.slot_1 is rw = 12; has $.slot_2 is rw = 24; method AT-POS(\position) { my $t = self; return-rw Proxy.new: FETCH => method () { position % 2 ?? $t.slot_1 !! $t.slot_2 }, STORE => method ($v) { if position % 2 { $t.slot_1 = $v }