ActiveSupport now adds an Array#rand method which returns a random element, this overrides Kernel#rand which returns a float.
I think that changing the line
point = rand * total
to
point = Kernel::rand * total
will fix this.
ActiveSupport now adds an Array#rand method which returns a random element, this overrides Kernel#rand which returns a float.
I think that changing the line
point = rand * total
to
point = Kernel::rand * total
will fix this.
Couldn't you just use Array#rand ?
///ark
I thought of suggesting that, but he's trying to do something similar, but with a parameter to provide a weighted distribution. The rand method in ActiveSupport only gives a uniform distribution.
It might be useful if this is only used with ActiveSupport to put something like
return rand unless weightt
at the top of the method though.