Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save librasteve/f609bd64655d64953b5956baa1db1e3a to your computer and use it in GitHub Desktop.
Save librasteve/f609bd64655d64953b5956baa1db1e3a to your computer and use it in GitHub Desktop.
Numeric Delegation Issue
#2023.04
role DataSlice does Positional does Iterable {
has Any @.data;
# Positional role support
# viz. https://docs.raku.org/type/Positional
method of {
Any
}
method elems {
@!data.elems
}
method AT-POS( $p ) {
@!data[$p]
}
method EXISTS-POS( $p ) {
0 <= $p < @!data.elems ?? True !! False
}
# Iterable role support
# viz. https://docs.raku.org/type/Iterable
method iterator {
@!data.iterator
}
method flat {
@!data.flat
}
method lazy {
@!data.lazy
}
method hyper {
@!data.hyper
}
}
my \dss = DataSlice.new( data => [1, 3, 5, 42, 6, 8] );
say ~dss;
say [+] dss.data; #65
say [+] dss;
#`[
Cannot resolve caller Numeric(DataSlice:D: ); none of these signatures matches:
(Mu:U \v: *%_)
in block <unit> at ./scum.raku line 43
#]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment