Hi Dave,

Thanks for the feedback and help! Definitely clarifies this. Didn't cover && as of yet in the book so wasn't aware of using it as an option.

I'll definitely try pseudocoding, think it could really help me think through some of this stuff.

Much appreciated.

-Emeka

Dave Aronson wrote in post #1036048:
> On Fri, Dec 9, 2011 at 19:14, Emeka Patrick <emekapatrick / gmail.com>
> wrote (rearranged a bit for illustrative purposes):
>
>> I got this program to work by rewriting it
>
> [from]
>
>> while true
>>  puts question
>>  reply = gets.chomp.downcase
>>
>>  if (reply != 'yes' || reply != 'no')
>>   puts 'Please answer "yes" or "no".'
>>  elsif reply == ''
>>  break
>>  end
>> end
>
> [to]
>
>>    end
>>  end
>
> The trick is that || means "or".  The first time, you're saying "if
> the reply isn't yes, or it isn't no, ask again, else if it's blank,
> break".  No matter what the reply is, it's either going to be not yes,
> or not no.  The second time, you're saying 'if it IS yes, or it IS no,
> break, else ask again (and if it's blank, break)".  If you want to use
> !=, what you need there is && (and) rather than || (or).
>
> If it helps, you can actually use the words "and" and "or" instead of
> the || and &&.  There are some situations in which there are
> differences, but in this case it should be OK.
>
> A general technique that might help is "pseudocoding".  Write out
> first, what it would look like in plain English (or whatever your
> native language is) if you were giving instructions to a person -- a
> fairly simple-minded person who is excellent at following instructions
> exactly as given (no matter how wrong they may be), very quickly.
> Read that over, trying to "think" like such a person.  Maybe even
> simulate it step by step by writing down the values of variables.
> When that gives you the results you want, then start translating it
> from English to Ruby.  That's how most people start out learning to
> program.  When you get good at it, then you can skip the English step.
>
> -Dave