Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Ruby Newbie - array/hash help
William Carpin
9/6/2006 2:47:00 PM
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.
--
Posted via
http://www.ruby-...
.
3 Answers
William Crawford
9/6/2006 3:30:00 PM
0
William Carpin wrote:
> 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.
Wouldn't that just be:
data_sources.each_key do |table_name|
puts table_name
end
(I'm not real sure how the whole datasource/tablename thing works in
ruby, but I was assuming datasources was a Hash once you got it.)
--
Posted via
http://www.ruby-...
.
Ara.T.Howard
9/6/2006 4:30:00 PM
0
William Crawford
9/6/2006 6:08:00 PM
0
unknown wrote:
>
> puts data_sources.keys
>
> ;-)
>
> -a
Heh yeah, but he wanted '...some code...'... I just put something in
there that worked. I assumed he wanted something quite a bit more
complex than that and that he could figure out that's where it went ;)
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Ruby Newbie - array/hash help
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