Hi John,

Thanks so much for getting back to me and for your kind words. Really 
big encouragement for someone just starting out and feeling a wee bit 
lost at times. As well, I must say the willingness of people in the Ruby 
community to offer help has really been pretty amazing.

John W Higgins wrote in post #1036028:
> Good Day Emeka,
>
> On Fri, Dec 9, 2011 at 12:47 PM, Emeka Patrick
> <emekapatrick / gmail.com>wrote:
>
>> Hi Robert,
>>
>> Thanks so much for getting back to me on this much appreciated. Some
>> questions in-line below.
>>
>
> Thank you for at least attempting to figure things out. Very refreshing
> in
> contrast to some of the questions that people pose here........

Thanks a bunch. Want to make sure I truly understand how and why things 
work when they do (or when they don't!)

>> >
>> >> '. Basically, I don't think I get what I'm making response equal to, is
>> >> it an empty string, or?
>> >
>> > != and == are tests and not assignments.  If you exchange == for !=
>> > you also need to exchange branches of the if else end construct.
>>
>> So basically with != and == I'm asking if what precedes the expression
>> is either "different from"  or "the same as" whatever follows. Am I
>> correct?
>>
>
> That would be correct.
>

Great!

>
>> Also, I still don't think I fully understand the empty string. In the
>> two lines of code...
>>
>> if response != ''
>> responses.push response
>>
>> ...am I doing something like "Is what was entered for the variable
>> response different from an empty string? If so then push whatever string
>> is entered to the end of the responses array."
>>
>
> That would also be correct. One other small item, normally code is
> indented
> (Ruby standard is 2 spaces) another level inside a control statement
> (if/while/else and such) to make it slightly easier to read the code.

I've been trying to do this as well as line up certain elements of code, 
but keep slipping in my enthusiasm to get it all out there. Def. need to 
try harder to keep it up. What about using Tab to indent, is there  any 
reason that might be frowned upon? Btw, I'm using TextMate.

>
> Taking your earlier work
>
> if response != ''
>   responses.push response
> else
>   puts responses.sort
>   break
> end
>
>
> It seemed to me that the logical way to enter this code would be
>>
>> responses = []
>> response = gets.chomp
>>
>> while response != ''
>>   responses.push response
>> end
>>
>> puts responses.sort
>>
>
> Actually very close here. Your problem is that you end up in an endless
> loop because you never get another entry from the user.
>
> This should do the trick
>
> responses = []
> response = gets.chomp
>
> while response != ''
>   responses.push response
>   response = gets.chomp # get another line from the user
> end
>
> puts responses.sort
>

Oh wow, ok, I think I get it. This is super clean too. Much nicer than 
what I originally had. Now, one last question, I need response = 
gets.chomp in the first instance just to define what the variable stands 
for, correct? It's not actually until the second instance where I'm 
soliciting input from the user, or actually is it more so the first 
instance both defines the variable and solicits  input from the user 
while the second instance solicits input in a continuous loop until it 
gets broken, i.e. when a user enters an empty string?

> But very very close for someone just picking up programming. You appear
> to
> at least grasp the basic mechanics of working through a problem!
>
> Best of luck to you!
>
> John

Thanks again John, super helpful! Almost done with chapter 9, "Writing 
Your Own Methods". Only 100 pages to go!

On another note, do you have any recommendations for Ruby resources 
and/or a path to take towards Ruby On Rails? I'm planning on finishing 
Learning to Program, doing the  Rails for Zombies courses, then diving 
into Michael Hartl's tutorial for Rails 2.3 and then reading Agile 
Development with Rails 3rd edition. Thoughts? Btw, I'm learning 2.3 as a 
site I had built was in 2.3.8 and I figure I should learn that first and 
then later learn 3 / 3.1.

Thanks,

Emeka

-- 
Posted via http://www.ruby-forum.com/.