yary wrote:
> A "roll" method was just added, though I don't think its implemented
> yet.
It is. .roll is what .pick(:replace) used to be, so it was "just" a
matter of splitting up the existing methods
$ ./perl6 -e 'say ~(1..6).roll(10)'
3 1 5 6 5 6 5 4 2 5
(works in Rakudo HEAD, and will work i
return round 1 + rand * $!sides;
Might be good to refer to http://perlcabal.org/syn/S32/Containers.html
for a more idiomatic way of picking an integer, eg "return
(1..$sides).pick"
A "roll" method was just added, though I don't think its implemented
yet. If you're only getting one value then
Phil Crow wrote:
> class Die;
>
> has Int $!sides;
>
> method new( Int $sides = 6 ) {
> return self.bless( *, :$sides );
> }
>
> method roll() returns Int {
> return round 1 + rand * $!sides;
> }
Just as a side note, this is could be easier written as
Background and Initial Questions
I'm excited to see such great advances in Rakudo and have enjoyed its
fundamental power and beauty. In reading Tim Bunce's blog, I saw a
call for an introduction to Perl 6 for Java programmers. Since Java
programming is a big part of my day job, I decided to see