Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,34 @@
# Reference:
# https://docs.raku.org/language/classtut
# https://github.com/teodozjan/perl-store
use v6;
use PerlStore::FileStore;
class Point {
has Int $.x;
has Int $.y;
}
class Rectangle does FileStore {
has Point $.lower;
has Point $.upper;
method area() returns Int {
($!upper.x - $!lower.x) * ( $!upper.y - $!lower.y);
}
}
my $r1 = Rectangle.new(lower => Point.new(x => 0, y => 0),
upper => Point.new(x => 10, y => 10));
say "Create Rectangle1 with area ",$r1.area();
say "Serialize Rectangle1 to object.dat";
$r1.to_file('./objects.dat');
say "";
say "take a peek on object.dat ..";
say slurp "./objects.dat";
say "";
say "Deserialize to Rectangle2";
my $r2 = from_file('objects.dat');
say "Rectangle2 is of type ", $r2.WHAT;
say "Rectangle2 area is ", $r2.area();