aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-027/yet-ebreo/perl6/ch-2.p623
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-027/yet-ebreo/perl6/ch-2.p6 b/challenge-027/yet-ebreo/perl6/ch-2.p6
new file mode 100644
index 0000000000..52f254c429
--- /dev/null
+++ b/challenge-027/yet-ebreo/perl6/ch-2.p6
@@ -0,0 +1,23 @@
+# Write a script that allows you to capture/display historical data. It could be an object or a scalar. For example
+# my $x = 10; $x = 20; $x -= 5;
+# After the above operations, it should list $x historical value in order.
+
+class hist {
+ has @.history;
+ has $!var handles <Str gist FETCH Numeric>;
+ method STORE($val) {
+ push @.history, $val;
+ $!var = $val;
+ }
+}
+
+my \x = hist.new(history => []);
+
+x = 10;
+x = 20;
+x -= 5;
+x = 3.1416;
+x = Q[a quick brown fox jumps over the lazy dog];
+x = 1e3;
+x*= sqrt 3;
+.say for x.history;