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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Looking for more Ruby-like way to create an array
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password