On Fri, Mar 26, 2010 at 9:32 AM, jamison edmonds <jamison2000e / yahoo.com> wrote: > Hello all > > Still new to programing. > I'm making a magic 8 ball clone, for fun and to learn by, console based for now. :) > > *** > I need a few good examples on how to detect if input has a question mark at the end (more than one example/explanation preferably.) > > So, I GETS a question in my .rb and if "string?" o.k. else I'd like to say, need a question with a ? mark at end please. > *** > > At <http://www.ruby-lang.org/en/> > [ > Ruby is... # Output "I love Ruby" > ---------------- say = "I love Ruby" > e pluribus puts say > unum, and such > :) # Output "I *LOVE* RUBY" > say['love'] = "*love*" > puts say.upcase > > # Output "I *love* Ruby" > # five times > 5.times { puts say } > ] > I see I can brake string's into parts, this may help me rite? > > Ruby rocks, thanks to all. require 'readline' puts "You will be talking to the awesome 8ball, type Control-d to finish your conversation." while line = Readline.readline('> ', true) if line.end_with?('?') puts "Consider it carefully." else puts "How about you ask some question?" end end -- Michael Fellinger CTO, The Rubyists, LLC