I'm New

First of all, let me just express my happiness at finally finding a
forum for Ruby, with a considerable base of users, (20 mins on a search
engine) Lol

Yeah I’m new
new to everything, I just decided to get into programming searched
programming found ruby and started following a guide.

I’ve had no programming experience before so if you guys know of
anything to help me out I might take a look at it.

and also I’ve got this little program problem:

puts ‘Speak up Sonny I can’t hear you.’
talk = gets.chomp
if talk == talk.capitalize or talk.downcase
then puts ‘What? Sonny speak louder! Like THIS.’
if talk == talk.upcase
then puts ‘no not since’
end
end

When you run it, and say something in Caps it returns both if puts
things so I don’t know how to fix it.
thanks.

From: [email protected] [mailto:[email protected]]

puts ‘Speak up Sonny I can't hear you.’

talk = gets.chomp

if talk == talk.capitalize or talk.downcase

then puts ‘What? Sonny speak louder! Like THIS.’

if talk == talk.upcase

then puts ‘no not since’

end

end

welcome to ruby!

simplify your program by asking simple/few if questions, and deducing fr
it.

compare it eg w,

puts “SPEAK up, Sonny, I can’t hear you.”
talk = gets.chomp
if talk == talk.upcase
puts ‘no not since’
else
puts ‘What? Sonny, speak louder! Like THIS.’
end

When you run it, and say something in Caps it returns both if puts

things so I don’t know how to fix it.

you had a problem along this line,

if talk == talk.capitalize or talk.downcase

talk.downcase always return true, ergo the whole or expression/condition
always returns true.

maybe you wanted

if talk == talk.capitalize or talk==talk.downcase

as you progess, you’ll probably then realize that this is a trivial
problem that you yourself can handily fix.

read more about ruby expressions and control structures. breakup
problems into smaller problems.

use irb. run one statement/expression at a time. check all possible
cases.

go slow first. stop if you need rest, but keep on studying/programming
:wink:

hth.

kind regards -botp

When I ran:

puts ‘Speak up Sonny I can’t hear you.’
talk = gets.chomp
if talk == talk.capitalize or talk == talk.downcase
then puts ‘What? Sonny speak louder! Like THIS.’
if talk == talk.upcase
then puts ‘no not since’
end
end

and used Caps it just ended the program… sorry if this is too trivial,
if it is maybe you guys could recommend a place where I wont be a
bother,

either way thanks.

NVM, I fixed it,

urgh sorry,

From: David Stanislaus [mailto:[email protected]]

puts ‘Speak up Sonny I can't hear you.’

talk = gets.chomp

if talk == talk.capitalize or talk == talk.downcase

then puts ‘What? Sonny speak louder! Like THIS.’

if talk == talk.upcase

then puts ‘no not since’

end

end

and used Caps it just ended the program… sorry if this is

too trivial,

if it is maybe you guys could recommend a place where I wont be a

bother,

we are glad that you are doing your best.

your if is structured like this,

if talk == talk.capitalize or talk == talk.downcase
puts ‘What? Sonny speak louder! Like THIS.’

if talk == talk.upcase
puts ‘no not since’
end
end

wc means that the 2nd if is nested inside the first if, ergo it does not
get called if you entered all caps.

another tip: use indentions (wisely)

kind regards -botp

On Mon, Jun 9, 2008 at 9:21 PM, David Stanislaus
[email protected]
wrote:

and used Caps it just ended the program… sorry if this is too trivial,
if it is maybe you guys could recommend a place where I wont be a
bother,

either way thanks.

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

David,

Although I am not sure what is it that you are trying to do, the
following
is one way to re-write your code and it does not abend!

*puts “Speak up Sonny I can't hear you”
talk = gets.chomp

if talk == talk.capitalize or talk == talk.downcase
puts “What? Sonny speak louder! Like THIS.”
else
if talk == talk.upcase
puts “no not since”
end
end*

But why don’t you tell us what you are trying to do and the forum might
be
able to recommend something better.

One last thing, beginner or not you don’t bother anyone. I am also still
a
beginner. Granted, you’ll find people that do not want to deal with
people
like you or I, but then you find another dozen that really will help us.

Victor