[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Looking for more Ruby-like way to create an array

Dan Diebolt

10/7/2008 9:44:00 PM

[Note: parts of this message were removed to make it a legal post.]

a=[1,2,3]
a.map (|item| 100*item}

--- On Tue, 10/7/08, Steve Nicholson <ssteve@mac.com> wrote:

From: Steve Nicholson <ssteve@mac.com>
Subject: Looking for more Ruby-like way to create an array
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Date: Tuesday, October 7, 2008, 5:33 PM

I'm creating an array that is the result of the members of another array
each multiplied by 100. Here's what I have:

converted_array = []
original_array.each {|line| converted_array << line.to_f * 100}

This works, but I'm wondering if there is a more idiomatically
"Ruby"
way of doing it.
--
Posted via http://www.ruby-....