From: Samantha Date: 2007-03-01T12:55:55+09:00 Subject: Re: Stepping out on a Limb - some very ugly code ------=_Part_55181_21309513.1172721351770 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 2/28/07, dblack@wobblini.net wrote: > > Hi -- > > > > > > ------------When I get to this point, if I typed in the answers to the > > prompts with the first letter capitalized (ie Samantha for the first > name), > > when the program verifies what I typed whatever values it is verifying, > as > > blank... > > That's because capitalize!, like a lot of bang methods, returns nil if > no change has occurred in the receiver. So David.capitalize! is nil. Ahhh, that makes sense. I tried it both ways, capitalizing and without capitalizing, and noticed that it had that behavior. I don't think I want to redefine the bang method (scary scary scary). But, what can I do to fix this? > puts("Your skills are as follows:\n") > > tech_skills.each do |skill| > > puts skill > > end > > It's much easier than that: > > puts tech_skills > > :-) *nod + laugh* I've done that in prior little things I've done - Donno why I didn't do that this time. > #This section gathers experience from the user. > > company1 = Hash.new > > ["Company Name","Company City","Company State","Start Date","End > > Date","Position Held","Job Duties"].each do |input| > > puts("Please enter your #{input}: ") > > company1 = gets.chomp > > That's wrong; it should be: > > company1[input] = gets.chomp > > since you want to set the relevant hash key. Also, make sure that > there's no newline between "End" and "Date", as that will cause > company1["End Date"] to be nil (as opposed to company1["End \nDate"]). > > > correct = boolean_prompt("You worked at " + company1["Company Name"] + " > as > > a " + company1["Position Held"] + " from " + company1["Start Date"] + " > > until " + company1["End Date"] + " and your job description was as > follows: > > \n" + company1["Job Duties"] + "\n" + company1["Company Name"] + " was > > located in " + company1["Company City"] + ", " + company1["Company > State"] + > > "Is this correct? ") > > Consider a here-document: > > prompt = < You worked at #{company1["Company Name"]} as a ... > (etc.) > EOM > > It will look more like the eventual output. Thanks, David. I'll definitely need to digest all of that and try using it in different ways. What I've been trying to do, is if someone gives me a suggestion, not only do I try and use it in what I'm working on, but I'm also trying to find another way to use it, that way it sinks in a little better. Thanks for the response, I really truly appreciate it. David > > -- > Q. What is THE Ruby book for Rails developers? > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) > (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > A. Ruby Power and Light, LLC (http://www.rubypal.com) > > -- 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_55181_21309513.1172721351770--