[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: join not in Enumerable

Eric Mahurin

5/22/2005 9:27:00 PM


--- "David A. Black" <dblack@wobblini.net> wrote:
> Hi --
>
> On Sun, 22 May 2005, Eric Mahurin wrote:
>
> > --- "David A. Black" <dblack@wobblini.net> wrote:
> >> I have to say, though, that I think #each_with_index
> should
> >> be removed
> >> from Enumerable and pushed down to the classes that mix it
> in
> >> (similarly to #each_index). But I suppose as long as they
> >> are called
> >> "enumerable" they are in some sense associated with a
> >> numerical index.
> >
> > Unfortunately for Hash, this can cause confusion to what an
> > "index" is. If it weren't for an already existing
> Hash#index
> > (which gets a key), I would suggest it be brought over from
> > Array to Enumerable.
>
> I see it the other way. "Index" means different things to
> different
> enumerables. I don't like the idea of having Enumerable
> define index
> as consecutive integers slapped onto the elements. I'd
> rather defer
> that to the classes -- as, indeed, it is, with the strange
> exception
> of each_with_index.

I was agreeing with you - each_with_index confuses what an
"index" is for Hash (or Hash#index does depending on how you
look at it).

> > I do tend to think that many of the Array methods should be
> > brought over to Enumerable. You could bring over just
> about
> > any one that is non-modifying and operates sequentially
> forward
> > on the array, but you may also restrict the ones related to
> an
> > "index":
> >
> > *, +, <=>, ==, assoc, compact, concat, empty?, eql?, first,
> > flatten, hash, join, last, length, nitems, pack, rassoc,
> size,
> > to_s, uniq
>
> Some of these would fare better than others.

agreed. I just listed all of them that were read-only and
operate sequentially forward in across the array. I think all
of these could be easily implemented in enumerable, but not all
make necessarily make sense.

> #flatten has no general
> meaning for an enumerable, since not all of them are
> recursive container objects.

Array#flatten only descends into Array elements, and an
Enumerable#flatten might only descend into Enumerable (or
Array) elements.

> I don't think you can #pack an arbitrary
> enumerable either. #size also doesn't work for enumerables
> in
> general, partly because some of them have no particular size
> and
> partly because even for those that do, taking the size might
> cause
> side-effects (e.g., an I/O-based enumerable).

Using any enumerable method with IO has the same issue. You'll
need to seek back between calls to any of the enumerable
methods on an IO.

Of course their is an easy (but not quite as efficient) way to
do any of the array methods on an enumerable: just call to_a
first (i.e. enum.to_a.join(" ") does a join for any
enumerable).





Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mai...



6 Answers

dblack

5/23/2005 1:38:00 AM

0

Mason Barge

7/20/2011 3:39:00 PM

0

On Wed, 20 Jul 2011 06:33:44 -0700 (PDT), The PHANTOM
<hoofhearted07@yahoo.com> wrote:

>On Jul 20, 7:28?am, RichA <rander3...@gmail.com> wrote:
>> On Jul 20, 5:14?am, Ubiquitous <web...@polaris.net> wrote:
>>
>> > On paper, the debt thing is boring, and many Americans are not paying
>> > attention.
>>
>> Like with credit cards and their waistlines.
>
>Niether one of which is any of your business.

Unfortunately both of them *are* my business, since I am expected to pay
for the results of their excess.

BR549

7/21/2011 11:33:00 AM

0

On Jul 20, 10:39 am, Mason Barge <masonba...@gmail.com> wrote:
> On Wed, 20 Jul 2011 06:33:44 -0700 (PDT), The PHANTOM
>
> <hoofhearte...@yahoo.com> wrote:
> >On Jul 20, 7:28 am, RichA <rander3...@gmail.com> wrote:
> >> On Jul 20, 5:14 am, Ubiquitous <web...@polaris.net> wrote:
>
> >> > On paper, the debt thing is boring, and many Americans are not paying
> >> > attention.
>
> >> Like with credit cards and their waistlines.
>
> >Niether one of which is any of your business.
>
> Unfortunately both of them *are* my business, since I am expected to pay
> for the results of their excess.

How?? Do you complain about paying for illegal invader's free
healthcare,food stamps,welfare,education and rent subsidies??

Mason Barge

7/21/2011 3:03:00 PM

0

On Thu, 21 Jul 2011 04:32:46 -0700 (PDT), The PHANTOM
<burtonurny@gmail.com> wrote:

>On Jul 20, 10:39?am, Mason Barge <masonba...@gmail.com> wrote:
>> On Wed, 20 Jul 2011 06:33:44 -0700 (PDT), The PHANTOM
>>
>> <hoofhearte...@yahoo.com> wrote:
>> >On Jul 20, 7:28?am, RichA <rander3...@gmail.com> wrote:
>> >> On Jul 20, 5:14?am, Ubiquitous <web...@polaris.net> wrote:
>>
>> >> > On paper, the debt thing is boring, and many Americans are not paying
>> >> > attention.
>>
>> >> Like with credit cards and their waistlines.
>>
>> >Niether one of which is any of your business.
>>
>> Unfortunately both of them *are* my business, since I am expected to pay
>> for the results of their excess.
>
>How?? Do you complain about paying for illegal invader's free
>healthcare,food stamps,welfare,education and rent subsidies??

Yes.

lorad

7/21/2011 4:29:00 PM

0



RichA <rander3127@gmail.com> wrote in message
news:ce0dfa21-ae50-42dc-aad4-4f3fbf555005@m22g2000yqh.googlegroups.com

> On Jul 20, 5:14=A0am, Ubiquitous <web...@polaris.net> wrote:
> > On paper, the debt thing is boring, and many Americans are not
paying
> > attention.
>
> Like with credit cards and their waistlines.
>

Actually, the future of America depends upon economics.

And with traitor ass republcans and traitor ass democrats having sent
some 20 million US jobs to commie china... things don't look too good.

Dano

7/21/2011 5:36:00 PM

0

"Uno Hu" wrote in message
news:1Nqdneh-xrJ0zrXTnZ2dnUVZ_o-dnZ2d@giganews.com...



RichA <rander3127@gmail.com> wrote in message
news:ce0dfa21-ae50-42dc-aad4-4f3fbf555005@m22g2000yqh.googlegroups.com

> On Jul 20, 5:14=A0am, Ubiquitous <web...@polaris.net> wrote:
> > On paper, the debt thing is boring, and many Americans are not
paying
> > attention.
>
> Like with credit cards and their waistlines.
>

Actually, the future of America depends upon economics.

And with traitor ass republcans and traitor ass democrats having sent
some 20 million US jobs to commie china... things don't look too good.

==============================================

Not to even mention or consider the interest China will earn from loaning us
all that money. You think they did this for humanitarian reasons?