We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 95fbb94 commit 4a314bfCopy full SHA for 4a314bf
t/nqp/58-attrs.t
@@ -3,16 +3,16 @@
3
plan(2);
4
5
class Foo {
6
- has $bar;
7
-
8
has $!answer;
9
- method question() { $!answer := 42 };
+ method question($what) { $!answer := $what }
+ method answer() { $!answer }
10
};
11
12
-my $foo := Foo.new;
+my $first := Foo.new;
+my $second := Foo.new;
13
14
-$foo.question();
15
-ok($foo.answer == 42, "Read-only accessors works");
+$first.question(42);
+$second.question(23);
16
+ok($first.answer == 42, "attributes work");
17
+ok($second.answer == 23, "... and are not shared among objects");
18
-$foo.bar(42);
-ok($foo.bar == 42, 'Read-write accessors works');
0 commit comments