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


Groups > comp.lang.ruby > #2237

Re: pipe question

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail
From wolf volpi <wolf_volpi@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: pipe question
Date Sun, 3 Apr 2011 23:55:59 -0500
Organization Service de news de lacave.net
Lines 41
Message-ID <69adf7ea6df8d60dfc1db2c7d6fdd29c@ruby-forum.com> (permalink)
References <6351ecc5d2ac52f4b4c9d06ad2930f2c@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 1301892980 26698 65.111.164.187 (4 Apr 2011 04:56:20 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Mon, 4 Apr 2011 04:56:20 +0000 (UTC)
In-Reply-To <6351ecc5d2ac52f4b4c9d06ad2930f2c@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 380887
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <69adf7ea6df8d60dfc1db2c7d6fdd29c@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:2237

Show key headers only | View raw


Ha Ha.  I was interpeting the pipes as empty arguments of an empty 
block, which made no sence to me.  Logical operators didn't even occure 
to me.  Seems funny now.  Thank you John and Josh for helping me see the 
light.

The || is a Logical OR Operator that returns the first true value (in 
Ruby anything besides false and nil is true).  I ran this demonstration 
in irb:
>> true || true
=> true
>> true || false
=> true
>> false || true
=> true
>> false || false
=> false

>> 1 || 2
=> 1
>> 1 || false
=> 1
>> false || 2
=> 2
>> false || false
=> false

>> 1 || 2
=> 1
>> 1 || nil
=> 1
>> nil || 2
=> 2
>> nil || nil
=> nil

>> nil || nil || 3 || 4
=> 3

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

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


Thread

pipe question wolf volpi <wolf_volpi@yahoo.com> - 2011-04-03 21:58 -0500
  Re: pipe question John Feminella <johnf@bitsbuilder.com> - 2011-04-03 22:08 -0500
    Re: pipe question Robert Klemme <shortcutter@googlemail.com> - 2011-04-04 02:36 -0500
  Re: pipe question Josh Cheek <josh.cheek@gmail.com> - 2011-04-03 22:42 -0500
    Re: pipe question Josh Cheek <josh.cheek@gmail.com> - 2011-04-04 04:58 -0500
      Re: pipe question Brian Candler <b.candler@pobox.com> - 2011-04-05 04:01 -0500
    Re: pipe question 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-04 19:12 -0500
      Re: pipe question Josh Cheek <josh.cheek@gmail.com> - 2011-04-04 22:30 -0500
        Re: pipe question Robert Klemme <shortcutter@googlemail.com> - 2011-04-05 10:27 -0500
        Re: pipe question 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-05 21:06 -0500
        Re: pipe question Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-06 02:00 -0500
      Re: pipe question Josh Cheek <josh.cheek@gmail.com> - 2011-04-05 21:23 -0500
  Re: pipe question wolf volpi <wolf_volpi@yahoo.com> - 2011-04-03 23:55 -0500

csiph-web