class Thing {
has Int $.my-value handles <gist Numeric>;
has Int $.other;
method my-value { self }
method other {
self.new:
:my-value($!other),
:other($!my-value)
}
method plus-oned {
self.clone: :my-value($!my-value + 1)
}
method less-oned {
self.clone: :my-value($!my-value - 1)
}
}
my $some = Thing.new:
:20my-value,
:0other,
;
say $some;
say $some.plus-oned;
say $some.less-oned;
say $some;
say $some.other;
say $some.other.plus-oned;
say $some.other.less-oned;
say $some.other;
say 22 + $some;
given $some {
.say;
say .plus-oned;
say .less-oned;
.say;
given .other {
.say;
say .plus-oned;
say .less-oned;
.say
}
}
say $some;
say $some.other;
say $some.other.other;
say $some.other.other.other;