[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03808] Re: Array.pick

From: "Conrad Schneiker" <schneiker@...>
Date: 2000-07-04 23:03:44 UTC
List: ruby-talk #3808
Hi,

"Aleksi Niemel" wrote

> I've found following snippet quite handy. Dunno if there's wider need for
> this.
>
> class Array
> def pick( count = -1 )
> if count >= 0
> ary = []
> count.times do
> ary << self.delete_at( rand( self.length ) )
> end
> return ary
> end
> self.delete_at( rand( self.length ) )
> end
> end

<snip>

Just a general comment--a brief statement of purpose and using conventional
indentation would be helpful. Apart from what should be the unnecessary work
of trying to figure out what was intended from the code, one still never
really knows for the author's original intent and how well the code actually
matches it.

Conrad



In This Thread