[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

newby question

Charles L. Snyder

6/18/2005 1:48:00 AM

How do I get each key (they are words /strings) to output on a new line in
this example?

File::open(title + '.htm', 'w') do |f|
hash.keys.each {|s| f.puts s}
......other stuff
end

-this results in all keys on one line

I've tried:
dict.keys.each {|s| f.puts s "\n"}
dict.keys.each {|s| f.puts s"\n"}
dict.keys.each {|s| f.puts ("#{s} \n"}
dict.keys.each {|s| f.puts s + " \n"}
dict.keys.each {|s| f.puts s + '\n'}
dict.keys.each {|s| f.puts s + \n}
etc ad nauseum

Sorry for asking such a simplistic question....

CLS


4 Answers

Ezra Zygmuntowicz

6/18/2005 2:00:00 AM

0

Since it looks like you are trying to output an html file maybe
replace the "\n" with "<br/>" or surround the entire block of test in
<pre></pre> tags might work?
On Jun 17, 2005, at 6:50 PM, Charles L. Snyder wrote:

> How do I get each key (they are words /strings) to output on a new
> line in
> this example?
>
> File::open(title + '.htm', 'w') do |f|
> hash.keys.each {|s| f.puts s}
> ......other stuff
> end
>
> -this results in all keys on one line
>
> I've tried:
> dict.keys.each {|s| f.puts s "\n"}
> dict.keys.each {|s| f.puts s"\n"}
> dict.keys.each {|s| f.puts ("#{s} \n"}
> dict.keys.each {|s| f.puts s + " \n"}
> dict.keys.each {|s| f.puts s + '\n'}
> dict.keys.each {|s| f.puts s + \n}
> etc ad nauseum
>
> Sorry for asking such a simplistic question....
>
> CLS
>
>
>

-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732



Charles L. Snyder

6/18/2005 3:29:00 AM

0

Doh...
That was it!
Thank you - I forgot the output was .htm.....
'purloined letter syndrome"

S'pion

10/22/2011 12:29:00 AM

0

Le 2011-10-21 17:28, B?stio del Giboudan a ?crit :
> A Srebrenica pendant deux ans, les milices musulmanes de Naser Oric,
> arm?es par les Amerloques, ont massacr? des civils isol?s dans des
> fermes.
>
> Ils en ont massacr? 34 000 avec une extr?me cruaut?.
>
> Au bout de deux ans l'arm?e serbe a vaincu les miliciens criminels
> contre l'Humanit?.
>
>
> Les Amerloques pleurent sur les miliciens, pas sur les civils.
>
> En 42-45 les Am?ricains ont lutt? contre le nazisme.
> A partir de 1968 il l'ont toujours soutenu, que ce soit sous la forme
> du shah d'Iran, de Pinochet, des talibans, d'Al Qa?da ou des
> salafistes libyens.


Chienne de vie, hein ?


Mara Jade Skywalker

10/22/2011 3:32:00 AM

0

Mara Jade ? S'pion:

> Bon flic, bon flic,
>
> http://www.youtube.com/watch?v=C...

J'ai bien ri...

--
Jacqueline "Jade" Devereaux - http://jacqueline-devereaux.blo...
antispam.cool@gmail.com [remplacez antispam.cool par jacquie.devereaux]
http://fr-fr.facebook.com/people/Jacqueline-Devereaux/10000...
Victor: "Tsahal correctionne grave, disperse menu, et ventile loin!"
Mara: "I feel a great disturbance in the Force across the Galaxy"