On Mar 6, 2004, at 11:54 AM, Charles Comstock wrote: > >> Please don't redefine a Kernel method. I think that's a Bad Idea(tm). >> Why not use #random instead? > > Why is redefining a kernel method to take a different class of > argument a bad idea? It's not like it changes existing functionality, > even if you had aliased it to take a range yourself, since your alias > would take effect before it hit the underlying version. I don't > understand why this is considered so bad. It hurts in static typed > languages sure, but with duck typing this doesn't hurt us. It's not redefining rand to take more varied arguments that's a bad thing, it's defining it for Array#rand that's a Bad Idea(tm), IMHO. Kernel is included in Object so that you can access it's methods easily within other objects. Redefining it in a subclass could potentially break lots of code. For example, I often do this: class Array def randomize() sort{rand(2)-0.5} end end ... and defining an Array#rand would break this. I like the idea of allowing Kernel.rand(range), for reasons already presented by others. Kernel.rand(array) seems a little iffy to me, but that's me. :) --Mark