[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Ruby Newbie - array/hash help

Berger, Daniel

9/6/2006 2:51:00 PM

> -----Original Message-----
> From: list-bounce@example.com
> [mailto:list-bounce@example.com] On Behalf Of William Carpin
> Sent: Wednesday, September 06, 2006 8:47 AM
> To: ruby-talk ML
> Subject: Ruby Newbie - array/hash help
>
>
> Given the following code...
>
>
> my $ds = new DataSources($dbh);
> my $data_sources = $ds->getTableNames();
>
> foreach my $table_name (keys %{$data_sources}){
> ...some code...
> }
>
>
> Is there any effective way to reproduce the above foreach
> loop in Ruby?
> I've been doing research, but I can't make heads or tails of it. Any
> assistance would be greatly appreciated.

data_sources.keys.each{ |table_name|
# some_code
}


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.

2 Answers

James Gray

9/6/2006 3:02:00 PM

0

On Sep 6, 2006, at 9:51 AM, Berger, Daniel wrote:

> data_sources.keys.each{ |table_name|
> # some_code
> }

Or:

data_sources.each_key { |table_name|
# ...
}

James Edward Gray II

Rimantas Liubertas

9/6/2006 3:13:00 PM

0

<...>
> data_sources.keys.each{ |table_name|
> # some_code
> }

Or:

data_sources.each_key { |table_name|
#some code
}

Regards,
Rimantas
--
http://rim...