Created
May 31, 2023 17:49
-
-
Save librasteve/f609bd64655d64953b5956baa1db1e3a to your computer and use it in GitHub Desktop.
Numeric Delegation Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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