[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

About 1.8.7 Array#map! without a block

Eustaquio 'TaQ' Rangel

6/3/2008 7:50:00 PM

Hi there.

I was wondering how to use Array#map! with a block. On the usual way, we
have

irb(main):001:0> a = [1,2,3]
=> [1, 2, 3]
irb(main):002:0> a.map! {|i| i*2}
=> [2, 4, 6]

Now with 1.8.7 we have:

irb(main):003:0> e = a.map!
=> #<Enumerable::Enumerator:0xb7db015c>
irb(main):004:0> e.next
=> 2
irb(main):005:0> a
=> [#<Generator:0xb7d9b9dc @queue=[4],
@cont_endp=#<Continuation:0xb7d9b1a8>, @index=1,
@block=#<Proc:0xb7da7ffc@/usr/local/lib/ruby/1.8/generator.rb:71>,
@cont_yield=#<Continuation:0xb7d9aed8>, @cont_next=nil>, 4, 6]
irb(main):006:0> a.size
=> 3

I got an Enumerable::Enumerator with a.map! and then the first call to
e.next returned me the first "a" element, 2. Ok, two questions:

1 - Since I created the Enumerable::Enumerator with map!, I presume it's
used on some way to change the elements on "a", so what should I use
with e.next to change the value, say, multiplying by 2 as on the first
case and have a [4,8,12] array on the end?

2 - Why I get a Generator on "a" elements when I just call e.next? The
cause it's what I'm missing to use with next, as asked on the first
question?

Thanks!

6 Answers

gumboman

8/11/2008 12:01:00 PM

0

On Sun, 10 Aug 2008 20:13:49 -0700, Evolution <myname@rcn.com> wrote:

>>
>
>Well you can see how scared they are... trying to keep her off the
>ballot... unprecedented.
>
>Laurie


I haven't been following it very much. WHat have they been doing?


D.F. Manno

8/12/2008 12:35:00 AM

0

In article
<cd49e4c3-a958-4b42-8649-57f61d26cc32@k30g2000hse.googlegroups.com>,
"Bevchcgo@gmail.com" <Bevchcgo@gmail.com> wrote:

> I know y'all won't agree with me, but I think Obama needs her on the
> ticket more than ever now that Edwards has wronged America. I think
> Hillary would be a strong VP and having Obama choose a woman who has
> been wronged by a male politician would send a great message about his
> own character -- and her's -- to the public. I don't see where
> they're trying to keep her off the ballot. She should be on the
> ballot. It gives the men and women who voted for her a voice.

It's not going to happen, no matter how much you threaten to hold your
breath till you turn blue. Clinton as the VP pick obviates his
campaign's theme (change), and neutralizes one of his biggest advantages
(the war).

--
D.F. Manno | dfmanno@mail.com
The modern conservative is engaged in one of man?s oldest exercises in
moral philosophy; that is, the search for a superior moral justification
for selfishness. (John Kenneth Galbraith)

A to Z

8/12/2008 2:55:00 AM

0


"Denise" <LuvTheBoss@aol.com> wrote in message
news:e4d4b6be-c653-4413-87cd-539d01159702@z72g2000hsb.googlegroups.com...
On Aug 11, 8:34?pm, "D.F. Manno" <dfma...@mail.com> wrote:

>
>> It's not going to happen, no matter how much you threaten to hold your
>> breath till you turn blue. Clinton as the VP pick obviates his
>> campaign's theme (change), and neutralizes one of his biggest advantages
>> (the war).
>


>Agreed. It's gonna be:
>1. Bayh (eh)
>2. Kaine (eh) or
>3. Richardson (YAY)

I'm not sure about the YAY for Richardson (not sure what he adds, besides
NM, whihc is a great state but not a lot of votes. I don't think that he
will pull the rest of the West with him.) BUt the "eh" for Kaine? Big time.
I don't think anyone here in his home state would be excited about him, and
does anyone outside of VA even know what he looks like, much less feel any
sort of enthusiasm for him?

of course, I don't have any better ideas.


Bluetele

8/12/2008 3:57:00 AM

0

It'd generate a lot of publicity if Obama selected his running mate by
holding a random draw sweepstakes. He could pick the winning name after the
election's over. That way, everyone who entered would have to vote for him,
or they'd might be giving up their chance to become Vice President. The
Veep Sweeps: Nobody wins unless Obama wins.

Evolution

8/12/2008 2:17:00 PM

0

Bluetele wrote:
> It'd generate a lot of publicity if Obama selected his running mate by
> holding a random draw sweepstakes. He could pick the winning name after
> the election's over. That way, everyone who entered would have to vote
> for him, or they'd might be giving up their chance to become Vice
> President. The Veep Sweeps: Nobody wins unless Obama wins.

LOL!

Laurie

Evolution

8/12/2008 2:33:00 PM

0

D.F. Manno wrote:
> In article
> <cd49e4c3-a958-4b42-8649-57f61d26cc32@k30g2000hse.googlegroups.com>,
> "Bevchcgo@gmail.com" <Bevchcgo@gmail.com> wrote:
>
>> I know y'all won't agree with me, but I think Obama needs her on the
>> ticket more than ever now that Edwards has wronged America. I think
>> Hillary would be a strong VP and having Obama choose a woman who has
>> been wronged by a male politician would send a great message about his
>> own character -- and her's -- to the public. I don't see where
>> they're trying to keep her off the ballot. She should be on the
>> ballot. It gives the men and women who voted for her a voice.
>
> It's not going to happen, no matter how much you threaten to hold your
> breath till you turn blue. Clinton as the VP pick obviates his
> campaign's theme (change), and neutralizes one of his biggest advantages
> (the war).
>

I think the cover has been blown from those two "themes" already... as
he has betrayed those ideals...

Laurie