Here is the definition of the subroutine from the Int class
proto sub is-prime($) is pure {*} multi sub is-prime(Int:D \i) { nqp::p6bool(nqp::isprime_I(nqp::decont(i), nqp::unbox_i(100))); } multi sub is-prime(\i) { i == i.floor && nqp::p6bool(nqp::isprime_I(nqp::decont(i.Int), nqp::unbox_i(100))); }
In the second, multi isprime_I converts its argument to .Int . Everything that this method has can then return an integer, which can be prime.
This imbalance is one of the things that I don't like about Perl 6. If we have a routine that can do it this way, we have to move the method higher in the class structure.
source share