[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Dividing inside iterations?

Dominic Son

7/23/2006 10:24:00 AM

Hi

Learning Ruby.

Is it possible to divide values while inside an iteration?

for example i'd like to do something like this:

h = [40,20,50,200]
h.each do |num,total| num / 24 = total
print "#{total} \n" end

as you'd expect, there is an error because of that '/' and '=' sign in
this iterator.

so since this isn't possible what would be the best way to do what i'm
trying to do? or perhaps my syntax is wrong

thank you very much.

Dominic

--
Posted via http://www.ruby-....

5 Answers

Dominic Son

7/23/2006 10:48:00 AM

0

Thanks for your quick reply Joey.

But it turns out you were wrong.

jk. it worked.

Thanks again man.

Dominic Son

Joey wrote:
> Yes, but in assignement the variable goes on the left.
> h = [40,20,50,200]
> h.each do |num,total|
> total = num / 24
> print "#{total} \n"
> end
>
> j`ey
> http://www.eachmap...


--
Posted via http://www.ruby-....

dblack

7/23/2006 11:25:00 AM

0

dblack

7/23/2006 2:42:00 PM

0

Nicklas

9/14/2008 5:26:00 PM

0

On Sun, 14 Sep 2008 12:37:59 -0400, Glue Bum
<ob@mas.ama> wrote:

>Nicklas@Click.com wrote:
>
>> Another fine example of hypocrisy of Thomas and the
>> conservatives
>>
>> He got to where he is today, because of Affirmative
>> Action.
>>
>how do u figure that? or did u just make it up?

Clarance Thomas, like Tom Sowell used affirmative
action to gain access to colleges, independent of their
intellectual ability.

Osamahelper

9/14/2008 5:53:00 PM

0

Nicklas@Click.com wrote:
> On Sun, 14 Sep 2008 12:37:59 -0400, Glue Bum
> <ob@mas.ama> wrote:
>
>> Nicklas@Click.com wrote:
>>
>>> Another fine example of hypocrisy of Thomas and the
>>> conservatives
>>>
>>> He got to where he is today, because of Affirmative
>>> Action.
>>>
>> how do u figure that? or did u just make it up?
>
> Clarance Thomas, like Tom Sowell used affirmative
> action to gain access to colleges, independent of their
> intellectual ability.
>
so u won't vote for Obama?