method set_value

Documentation for method set_value assembled from the following types:

class Attribute

From Attribute

(Attribute) method set_value

Defined as:

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.speak# OUTPUT: «5␤» 
$a.speak# OUTPUT: «42␤»

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