From: Samantha Date: 2007-03-01T05:08:36+09:00 Subject: Re: Stepping out on a Limb - some very ugly code ------=_Part_46342_711609.1172693299743 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 2/28/07, Sebastian Hungerecker wrote: > > Am Mittwoch, 28. Februar 2007 20:52:44 schrieb Samantha: > > On 2/28/07, Samantha wrote: > > > On 2/28/07, Sebastian Hungerecker wrote: > > > > > data=Hash.new > > > > ["street number","street name","city name","state","zip code"].each > do > > > > |i| > > > > puts("Please enter your #{i}: ") > > > > data[i]=gets.chomp > > > > end > > > Okay ... I wrote that up and it inputs things, but I have a few > > questions... > > > > 1) After getting the information from the user, I want to be able to > output > > the information on the screen and get a confirmation. I'm assuming that > I > > do that with: > > > > contact_info.each do |i| > > puts i > > end > > > > Yes? So... 1) How do I get this to be 'pretty' or formatted nicely like > > the original code, and 2) How do I get the state abbreviation as all > > upcase? > > Just use contact_info["x"] to access information x (e.g. > contact_info["street > name"] to access the street name), assuming contact_info is what you > called > the hash (although I would recommend just calling it info, because that's > less > to type ;-) ) Gotcha, so... i'd type puts contact_info["state_name"].upcase to access and change the state abbreviation to all uppercase, then, yes? :) Thanks again for being so helpful! Being that I wrote out the 'procedural' type code before, I am going to use all these tips and rewrite the same program piece and add on to it, using different techniques... :) -- > Ist so, weil ist so > Bleibt so, weil war so > > -- Samantha http://www.babygeek.org/ "Beware when the great God lets loose a thinker on this planet. Then all things are at risk." --Ralph Waldo Emerson ------=_Part_46342_711609.1172693299743--