set_value
ErrorsCollection

set_value

Synthesised documentation from type/Attribute

From type/Attribute

See Original text in context

method set_value(Mu $objMu \new_val)

Binds the value new_val to this attribute of object $obj.

class A {
    has $!a = 5;
    method speak() { say $!a}
}
my $attr = A.^attributes(:local)[0];
my $a = A.new;
$a.speak# OUTPUT: «5␤» 
$attr.set_value($a42);
$a.speak# OUTPUT: «42␤»

Note that this method violates encapsulation of the object, and should be used with care. Here be dragons.