<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: A trap to avoid with ruby assignments</title>
	<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/</link>
	<description>Because programming should be fun</description>
	<pubDate>Tue, 06 Jan 2009 04:16:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>

	<item>
		<title>By: Ben</title>
		<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-27</link>
		<author>Ben</author>
		<pubDate>Mon, 26 Mar 2007 17:34:14 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-27</guid>
					<description>The difference between the first and second cases is that instance variables in Ruby are essentially protected by default. There is no trap; assignment in Ruby is always performed using a method call.</description>
		<content:encoded><![CDATA[<p>The difference between the first and second cases is that instance variables in Ruby are essentially protected by default. There is no trap; assignment in Ruby is always performed using a method call.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-28</link>
		<author>Frank</author>
		<pubDate>Mon, 26 Mar 2007 19:03:52 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-28</guid>
					<description>Ben,

I'm not sure to understand what you mean. if I write obj = MyClass.new, the equal sign isn't "bound" to any method name. This is what i was talking about.</description>
		<content:encoded><![CDATA[<p>Ben,</p>
<p>I&#8217;m not sure to understand what you mean. if I write obj = MyClass.new, the equal sign isn&#8217;t &#8220;bound&#8221; to any method name. This is what i was talking about.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Hugo</title>
		<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-29</link>
		<author>Hugo</author>
		<pubDate>Mon, 26 Mar 2007 19:41:11 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-29</guid>
					<description>Hi, I'm currently learning Ruby ( and, sure, Rails) and found your posts very interesting. I'm start to understanding the whole thing behind Ruby and all beauty of the language :)

I understood why I use symbols all the times in Rails..

Tks</description>
		<content:encoded><![CDATA[<p>Hi, I&#8217;m currently learning Ruby ( and, sure, Rails) and found your posts very interesting. I&#8217;m start to understanding the whole thing behind Ruby and all beauty of the language <img src='http://www.rubyfleebie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I understood why I use symbols all the times in Rails..</p>
<p>Tks</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-30</link>
		<author>Ben</author>
		<pubDate>Mon, 26 Mar 2007 19:54:05 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-30</guid>
					<description>My mistake. For the longest time, I'd assumed that every action boiled down to a method call in Ruby. Guess not:

&lt;code&gt;$ irb
irb&#62; hello = 'ted'
=&#62; 'ted'
irb&#62; def hello; 'bob'; end
=&#62; nil
irb&#62; hello
=&#62; 'ted'
irb&#62; hello()
=&#62; 'bob'
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>My mistake. For the longest time, I&#8217;d assumed that every action boiled down to a method call in Ruby. Guess not:</p>
<p><code>$ irb<br />
irb&gt; hello = 'ted'<br />
=&gt; 'ted'<br />
irb&gt; def hello; 'bob'; end<br />
=&gt; nil<br />
irb&gt; hello<br />
=&gt; 'ted'<br />
irb&gt; hello()<br />
=&gt; 'bob'<br />
</code></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jörg W Mittag</title>
		<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-32</link>
		<author>Jörg W Mittag</author>
		<pubDate>Mon, 26 Mar 2007 21:41:29 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-32</guid>
					<description>There's one more way to create readers and writers, somewhere in between writing your own and calling attr_accessor or attr_reader: attr.  attr takes a Symbol and an optional Boolean.  The Symbol is the name of the accessor and the Boolean determines whether a writer is also created.  The created accessor methods basically look exactly like the ones you demonstrated.

attr_accessor and attr_reader take any number of Symbols and basically just call attr(:sym, true) or attr(:sym) for each one.

However, I have no idea why and when one would actually want to use attr over attr_accessor.

jwm</description>
		<content:encoded><![CDATA[<p>There&#8217;s one more way to create readers and writers, somewhere in between writing your own and calling attr_accessor or attr_reader: attr.  attr takes a Symbol and an optional Boolean.  The Symbol is the name of the accessor and the Boolean determines whether a writer is also created.  The created accessor methods basically look exactly like the ones you demonstrated.</p>
<p>attr_accessor and attr_reader take any number of Symbols and basically just call attr(:sym, true) or attr(:sym) for each one.</p>
<p>However, I have no idea why and when one would actually want to use attr over attr_accessor.</p>
<p>jwm</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-33</link>
		<author>Frank</author>
		<pubDate>Mon, 26 Mar 2007 23:57:36 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-33</guid>
					<description>Thanks everyone for your comments, i really appreciate. Hugo, your comment made my day. Knowing that some people appreciate my work means a lot to me. It's cool to see your interest in the language. Ruby is one wild beast but to me it's the most interesting and elegant language out there.

Jörg, I didn't know about the attr keyword. Thanks for the input! Like you said however, I don't know why one would use it instead of the other more "verbose" helpers...

Is it some deprecated feature?</description>
		<content:encoded><![CDATA[<p>Thanks everyone for your comments, i really appreciate. Hugo, your comment made my day. Knowing that some people appreciate my work means a lot to me. It&#8217;s cool to see your interest in the language. Ruby is one wild beast but to me it&#8217;s the most interesting and elegant language out there.</p>
<p>Jörg, I didn&#8217;t know about the attr keyword. Thanks for the input! Like you said however, I don&#8217;t know why one would use it instead of the other more &#8220;verbose&#8221; helpers&#8230;</p>
<p>Is it some deprecated feature?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: sole</title>
		<link>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-34</link>
		<author>sole</author>
		<pubDate>Tue, 27 Mar 2007 07:10:26 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/a-trap-to-avoid-with-ruby-assignments/#comment-34</guid>
					<description>Cool one! I already *supposedly* knew this but reading it again it helped clarifying and settling the concepts. Coming from a non-ruby background, I always forget how the attributes and accessors work in ruby :D</description>
		<content:encoded><![CDATA[<p>Cool one! I already *supposedly* knew this but reading it again it helped clarifying and settling the concepts. Coming from a non-ruby background, I always forget how the attributes and accessors work in ruby <img src='http://www.rubyfleebie.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
				</item>
</channel>
</rss>
