From: Chris Moore Date: 2001-08-04T23:31:31+09:00 Subject: [ruby-talk:19137] Re: My 1st look @ ruby: No prototypes and problem On August 4, 2001 06:51 am, you wrote: > "David Alan Black" wrote in message > news:g9Sa7.35691$WD1.1946407@e420r-atl2.usenetserver.com... > > > class. Shuffling is a more method-like concept. It's also a general > > enough thing that you could make a case for adding it directly to > > class Array. .... > Another useful method is rotate(n). Rotate is modulo length and can be > signed to rotate in the other direction. Note that negative modulo should > be used with care in this case because signed modulo has different > interpretations. Here it means the same as modulo the absolute value, - > "just in the other direction". > The positive direction is from lower index to higher index. > > Mikkel Both of these are pretty cool... are these in class array already? I guess if they aren't I can just write an implementation to mixin anytime I want that. I did the same thing for dice to use a standard RPG notation: class Fixnum def d(m) total = 0 self.times { total += rand(m).to_i +1 } return total end end >3.d6 13 >3.d6 12 >3.d6 5 #crap! ;)