Re: Enumerable#unassociate

2012-06-25 Thread Robert Klemme
On Mon, Jun 25, 2012 at 9:57 PM, Intransition wrote: >> On Monday, June 25, 2012 12:00:01 PM UTC-4, Robert Klemme wrote: >>> >>> And what's the use case for *that* method? > > >  To convert an Enumerable to a Hash. Sorry, I should have specified that. But not only that: you need a Hash as input t

Re: Enumerable#unassociate

2012-06-25 Thread Intransition
> > On Monday, June 25, 2012 12:00:01 PM UTC-4, Robert Klemme wrote: And what's the use case for *that* method? > > To convert an Enumerable to a Hash. Sorry, I should have specified that. > I have no name for it yet, so call it #h. >> > >> > # Convert an Enumerable object to a Hash. >>

Re: Enumerable#unassociate

2012-06-25 Thread Robert Klemme
On Mon, Jun 25, 2012 at 4:59 PM, Intransition wrote: > On Monday, June 25, 2012 2:38:48 AM UTC-4, Robert Klemme wrote: >> >> What's the use case for this? > > In my case it's supplemental to another method I am working on. And what's the use case for *that* method? > I have no name for it yet, s

Re: Enumerable#unassociate

2012-06-25 Thread Intransition
On Monday, June 25, 2012 2:38:48 AM UTC-4, Robert Klemme wrote: > What's the use case for this? > In my case it's supplemental to another method I am working on. I have no name for it yet, so call it #h. # Convert an Enumerable object to a Hash. # # [:a, 1, :b, 2].h # #=> {:a=>1, :

Re: Enumerable#unassociate

2012-06-24 Thread Robert Klemme
On Mon, Jun 25, 2012 at 1:35 AM, Intransition wrote: > Have a look: > >   module Enumerable > >     # Take an associative array and unassociate it. >     # >     #   [[:a,1], [:b,2]].unassociate.to_a     #=> [:a, [1], :b, [2]] >     #   [[:a,1], [:b,2]].unassociate(1).to_a  #=> [:a, 1, :b, 2] >  

Enumerable#unassociate

2012-06-24 Thread Intransition
Have a look: module Enumerable # Take an associative array and unassociate it. # # [[:a,1], [:b,2]].unassociate.to_a #=> [:a, [1], :b, [2]] # [[:a,1], [:b,2]].unassociate(1).to_a #=> [:a, 1, :b, 2] # def unassociate(index = 1..-1) return to_enum(:unassocia