[#18121] [Ruby 1.8.7 - Bug #405] (Open) ssl.rb:31: [BUG] Bus Error — Anonymous <redmine@...>

Issue #405 has been reported by Anonymous.

14 messages 2008/08/04

[#18130] Re: New array methods cycle, choice, shuffle (plus bug in cycle) — Brian Candler <B.Candler@...>

> Seriously though... Array.first is a noun.

10 messages 2008/08/05

[#18319] NEW Command: absolute_path() -- — "C.E. Thornton" <admin@...>

Core,

14 messages 2008/08/16
[#18321] Re: NEW Command: absolute_path() -- — Yukihiro Matsumoto <matz@...> 2008/08/18

Hi,

[#18381] [Bug #496] DRb.start_service(nil) is very slow — Hongli Lai <redmine@...>

Bug #496: DRb.start_service(nil) is very slow

11 messages 2008/08/25

[ruby-core:18096] Re: New array methods cycle, choice, shuffle (plus bug in cycle)

From: gdefty@...
Date: 2008-08-03 10:51:42 UTC
List: ruby-core #18096
Matz,

My vote would also go with my suggestion ( ;-) )

Array#sample is 
- clear (to my mind)
- concise (i.e. short!)
- makes sense if the method returns one or many
elements, AND
- satisfies both the method-as-noun and
method-as-verb views.

I would also put in a vote for a ! variant (as
suggested by Charles Nutter) which removes the
returned elements so that they will not be
selected a second time.

regards,

graeme

---- Original Message ----

From: James Gray <james@grayproductions.net>
To: ruby-core@ruby-lang.org
Cc: 
Subject: [ruby-core:18084] Re: New array methods
cycle, choice, shuffle (plus bug in cycle)
Date: Sun, August 03, 2008, 01:00:00

On Aug 2, 2008, at 5:15 AM, Yukihiro Matsumoto wrote:

> Here are choices:
>
> * Array#rand (or random, or random_element):
pick one random element
>  from an array.  some might confuse the method
to behave like
>  #shuffle though.

There's probably not a big chance of
random_element() being confused.

> * Array#sample: this method can take an optional
argument for element
>  number.  Like #first, the method returns an
array if an argument is
>  given.

So sample() would return one element, while
sample(1) would return a  
one element Array?  I really like that option.

James Edward Gray II




In This Thread

Prev Next