Hi Robert,

Thanks so much for getting back to me on this much appreciated. Some 
questions in-line below.

Robert Klemme wrote in post #1035877:
> On Fri, Dec 9, 2011 at 9:58 AM, Emeka Patrick <emekapatrick / gmail.com>
> wrote:
>> Super new to programming (1 week or so) and working through 'Learn to
>> Program' to get an understanding of Ruby before moving on to trying my
>> hand at Ruby on Rails. That being said I was having a bit of trouble
>> working through the first "A Few Things To Try" in section 8.3.
>
> Welcome to the world of Ruby!
>
>> '. 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?

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."

>> response = gets.chomp
>>
>> if response != ''
>> responses.push response
>>
>> else
>> puts responses.sort
>> break
>> end
>> end
>
> As an additional task you could try to rewrite your program to not use
> an endless loop ("while true") but rather use the fact that the input
> was the empty string as termination condition for the loop.  This
> would be more natural than breaking out of the loop.  The result will
> look something like this:
>
> responses = []
> ???
>
> while ???
>   responses.push response
> end
>
> puts responses.sort
>
> Where "???" are placeholders your code.

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

However, it's not working. Any ideas what I'm missing with this?

>
> Kind regards
>
> robert

Thanks again,

Emeka

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