<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Ruby boolean operator (or ruby parsing) bug</title>
	<atom:link href="http://adamloving.com/internet-programming/ruby-boolean-operator-or-ruby-parsing-bug/feed" rel="self" type="application/rss+xml" />
	<link>http://adamloving.com/internet-programming/ruby-boolean-operator-or-ruby-parsing-bug</link>
	<description>Seattle Social Web Development</description>
	<lastBuildDate>Thu, 06 May 2010 12:25:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aaron</title>
		<link>http://adamloving.com/internet-programming/ruby-boolean-operator-or-ruby-parsing-bug/comment-page-1#comment-199</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Thu, 10 Jul 2008 14:53:49 +0000</pubDate>
		<guid isPermaLink="false">http://adamloving.com/?p=399#comment-199</guid>
		<description>This isn&#039;t a bug.  The operator &#039;or&#039; is below the operator &#039;=&#039; in the order of operations, and the operator &#039;&#124;&#124;&#039; is above &#039;=&#039;.  (This is documented in the section &#039;Operator Expressions&#039; here http://docs.huihoo.com/ruby/ruby-man-1.4/syntax.html.)

So Ruby parses your first assertion as x = (false &#124;&#124; true), and does just what you want.  But it parses your second one as (z = false) or true, which means it assigns z to the value of false, and then returns the value true.

If you change your second statement to &#039;z = (false or true)&#039;, it should work.  Personally, I just avoid that &#039;or&#039; operator in favor of the &#039;&#124;&#124;&#039; operator, because I don&#039;t want to deal with stuff like this.</description>
		<content:encoded><![CDATA[<p>This isn&#8217;t a bug.  The operator &#8216;or&#8217; is below the operator &#8216;=&#8217; in the order of operations, and the operator &#8216;||&#8217; is above &#8216;=&#8217;.  (This is documented in the section &#8216;Operator Expressions&#8217; here <a href="http://docs.huihoo.com/ruby/ruby-man-1.4/syntax.html" rel="nofollow">http://docs.huihoo.com/ruby/ruby-man-1.4/syntax.html</a>.)</p>
<p>So Ruby parses your first assertion as x = (false || true), and does just what you want.  But it parses your second one as (z = false) or true, which means it assigns z to the value of false, and then returns the value true.</p>
<p>If you change your second statement to &#8216;z = (false or true)&#8217;, it should work.  Personally, I just avoid that &#8216;or&#8217; operator in favor of the &#8216;||&#8217; operator, because I don&#8217;t want to deal with stuff like this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
