Browse files

make Int.rand return a random Int if the invocant is too big to becom…

…e a Num
  • Loading branch information...
1 parent e015e40 commit 59dd40fa6b6eec1688e2b8a1f4a35cdad7d50e64 @moritz moritz committed Sep 22, 2012
Showing with 6 additions and 1 deletion.
  1. +5 −0 src/core/Int.pm
  2. +1 −1 tools/build/NQP_REVISION
View
5 src/core/Int.pm
@@ -64,6 +64,11 @@ my class Int does Real {
method floor(Int:D:) { self }
method round(Int:D:) { self }
method ceiling(Int:D:) { self }
+
+ method rand(Int:D) {
+ my num $n = nqp::tonum_I(self);
+ $n === $Inf ?? nqp::rand_I(self, Int) !! $n.rand;
+ }
}
multi prefix:<++>(Int:D \a is rw) { # XXX
View
2 tools/build/NQP_REVISION
@@ -1 +1 @@
-2012.09-2-gc458a08
+2012.09-3-g8ae6f20

0 comments on commit 59dd40f

Please sign in to comment.