Help language development. Donate to The Perl Foundation
Rake - raking typed values together in a list
use Rake; my $foo = Rake[Int,Str,IO].new(42,"bar","filename".IO); say $foo; # 42 say $foo; # bar say $foo; # "filename".IO .say for $foo; # 42␤bar␤"filename".IO␤ say $foo.^name; # Rake[Int,Str,IO] my @bar := Rake[Int,Int].new(42,666); my @baz is Rake[Int,Int] = 42,666; # if Raku allows
The Rake class (actually, a punned role) allows one to create an ad-hoc collection of typed objects without the need to use a hash, list or class. It only accepts values that smartmatch the given types on creation of the collection and provides immutable positional values from the result.
It can be iterated over and be passed around as a single object.
Inspired by the remarks of
Elizabeth Mattijsen [email protected]
Source can be located at: https://github.com/lizmat/Rake . Comments and Pull Requests are welcome.
Copyright 2020 Elizabeth Mattijsen
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.