From: Michael Fellinger Date: 2010-03-26T12:13:08+09:00 Subject: Re: end of sentience has ? y/n, if n please use one "string?"=o.k. On Fri, Mar 26, 2010 at 9:32 AM, jamison edmonds 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 > [ > 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