-
-
Save anonymous/ee9caad3bc145cdfef37 to your computer and use it in GitHub Desktop.
failing with error : Cannot look up attributes in a type object
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
class MyInt is Int { | |
method square(){ | |
self * self; | |
} | |
class Prime { | |
has $.start is rw = 2; | |
method is_prime(MyInt $val){ | |
my Bool $flag = True; | |
loop { | |
last if $!start >= $val; | |
do { | |
$flag = False; | |
last; | |
} if $val % $!start == 0; | |
$!start += 1; | |
} | |
return $flag; | |
} | |
} | |
method test(){ | |
Prime.is_prime(self); | |
} | |
} | |
print (1..10).eager.map(->$x { MyInt.new($x) }).grep(*.test).map(*.square); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment