Chris Logan wrote:
> Hello all im really new to ruby as in a few days and getting into it. i
> was following a tutorial found on
> http://pine.fm/LearnToProgram/?Chapter=00 in later chapters it made a
> challenge to write a program involving a looping a deaf grandma i
> started it and have it for the most part working buts its doing a few
> things that i dont fully understand im guessing these are bugs O.o?
> 
>   reply = ' '
>   replytt = ' '
> puts 'Ahh theres my grandson'
>   while replytt != 'BYE'
>   while reply != 'BYE'
>     reply = gets.chomp
>   if reply == reply.upcase
>     puts 'No not since 19' + (rand(5)).to_s + (rand(10)).to_s + '!'
> reply = gets.chomp
>   else
>     puts 'WHAT\'S THAT SONNY SPEAK UP!'
>     reply = gets.chomp
> end
> end
>   if reply == 'BYE'
>     puts 'Do you really have to go?'
>     replyt = gets.chomp
>     reply = replyt
>   if replyt == 'BYE'
>     puts 'Don\'t you wanna hear about the time I met your granda?'
>     replytt = gets.chomp
>     replyt = replytt
>     reply = replyt
>   else
>     puts 'WHAT\'S THAT SONNY SPEAK UP!'
>     replyt = replytt
>     reply = replyt
>     reply = gets.chomp
> end
> end
> end
> puts 'Come back and visit your old granny again soon.'
> puts 'Ill tell you the time I...'
> puts 'zzzz...'
> 
> a few things first off since i cannot seem to find it on google i dont
> know how to make rand pop out anything thats not 0

What output do you get for this:

puts 'No not since 19' + (rand(5)).to_s + (rand(10)).to_s + '!'

and what about this:

puts rand(5)
puts rand(10)

> for
> instance i wanted it to be like the tutorial said and make it 1930- 1950
> for the year 

For the 30-50 part, how about getting a random number that is greater 
than or equal to 0 and less than 20 and then adding 30 to it?


> the second is during if reply == reply.upcase it gives me a
> blank line i have to hit enter again before it gives the No not since
> [year] 

In your opinion, what does the last line here do:

>   reply = gets.chomp
>   if reply == reply.upcase
>     puts 'No not since 19' + (rand(5)).to_s + (rand(10)).to_s + '!'
>     reply = gets.chomp


> also during the second BYE if replyt == 'BYE' even if i put an
> answer that isnt in caps lock it gives it me a respons as if it was.
>

Your code is a mess.  You need to choose an indenting format.  Here is 
what I recommend:

x = 1

while x != 10
  if x == 1
    puts "hello"
  end

  break
end


Note:

1) The first "end" is indented the same amount as 'if', and denotes the 
end of the if statement.
2) Everything inside the while statement is indented more than 'while'
3) The last 'end' matches the indenting of 'while', and denotes the end 
of the while loop.

Without proper indenting, you will never be able to follow the logic of 
your code.
-- 
Posted via http://www.ruby-forum.com/.