Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4101

Re: Help with while condition OR condition

Path csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail
From 7stud -- <bbxx789_05ss@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: Help with while condition OR condition
Date Sat, 7 May 2011 21:29:23 -0500
Organization Service de news de lacave.net
Lines 25
Message-ID <21f342aaa24993413edad3ec1e101650@ruby-forum.com> (permalink)
References <fe6567119d5fbe466a7c6d2885d4718a@ruby-forum.com>
NNTP-Posting-Host bristol.highgroove.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace talisker.lacave.net 1304821772 51428 65.111.164.187 (8 May 2011 02:29:32 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Sun, 8 May 2011 02:29:32 +0000 (UTC)
In-Reply-To <fe6567119d5fbe466a7c6d2885d4718a@ruby-forum.com>
X-Received-From This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway
X-Mail-Count 382811
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <21f342aaa24993413edad3ec1e101650@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:4101

Show key headers only | View raw


Hi,

A lot of beginners make the same mistake you did.   'Compound 
conditionals' have to be written like separate conditionals and then 
hooked together with an 'or' or 'and'.  For instance if you wanted to do 
something only if a number were greater than 5 and less then 10, you 
would do this:

x > 5
x < 10
and

if x > 5 and x < 10
  #do something
end

Everyone should use 'and' and 'or' by default instead of && and ||. 
Code reads better that way.  Only if you have a specific reason to, 
should you use && or ||.

Good luck.

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

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help with while condition OR condition "Bill W." <sirwillard42@gmail.com> - 2011-05-07 17:37 -0500
  Re: Help with while condition OR condition Steve Klabnik <steve@steveklabnik.com> - 2011-05-07 17:52 -0500
  Re: Help with while condition OR condition Christopher Dicely <cmdicely@gmail.com> - 2011-05-07 17:53 -0500
  Re: Help with while condition OR condition John Feminella <johnf@bitsbuilder.com> - 2011-05-07 17:54 -0500
    Re: Help with while condition OR condition John Feminella <johnf@bitsbuilder.com> - 2011-05-07 17:55 -0500
  Re: Help with while condition OR condition Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-05-07 17:56 -0500
  Re: Help with while condition OR condition Hashmal <jeremypinat@gmail.com> - 2011-05-08 01:06 +0200
  Re: Help with while condition OR condition "Bill W." <sirwillard42@gmail.com> - 2011-05-07 18:38 -0500
  Re: Help with while condition OR condition Josh Cheek <josh.cheek@gmail.com> - 2011-05-07 20:15 -0500
  Re: Help with while condition OR condition 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-07 21:29 -0500
    Re: Help with while condition OR condition John Feminella <johnf@bitsbuilder.com> - 2011-05-07 21:48 -0500
    Re: Help with while condition OR condition Brian Candler <b.candler@pobox.com> - 2011-05-08 09:45 -0500
      Re: Help with while condition OR condition 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-09 15:11 -0500
        Re: Help with while condition OR condition Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-05-09 16:42 -0500

csiph-web