<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">I was just playing around in irb, and
it seems to work... I didn't look into it theoretically, but when
the map and the terrain don't match, I tend to trust the terrain.<br>
<br>
irb(main):001:0> def foo<br>
irb(main):002:1> @bar ||= []<br>
irb(main):003:1> end<br>
=> nil<br>
irb(main):004:0> def foo= obj<br>
irb(main):005:1> @bar = obj<br>
irb(main):006:1> end<br>
=> nil<br>
irb(main):007:0> foo<br>
=> []<br>
irb(main):008:0> foo + ["a"]<br>
=> ["a"]<br>
irb(main):009:0> foo = ["b"]<br>
=> ["b"]<br>
irb(main):010:0> foo += ["c"]<br>
=> ["b", "c"]<br>
<br>
<br>
On 01/07/14 17:46, Gabe da Silveira wrote:<br>
</div>
<blockquote
cite="mid:CAGPQN9NsMQAPvcrk0468jNZFnR+QKYBVFdvQVgOOjF1crvQOcQ@mail.gmail.com"
type="cite">
<div dir="ltr">That will do absolutely nothing since he's not
calling self.foo=<br>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Tue, Jul 1, 2014 at 10:36 AM,
Ronny Ager-Wick <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:ronny@ager-wick.com"
target="_blank">ronny@ager-wick.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>You don't have any definition for what should
happen to foo when assigning a value.<br>
Try adding this:<br>
<br>
def foo= obj<br>
@b = obj<br>
end
<div>
<div class="h5"><br>
<br>
<br>
On 01/07/14 17:12, Kenneth Lee wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<div dir="ltr">
<p>Doing some lazy instantiation and come across
this oddity, maybe I'm just being dense.</p>
<p><font face="courier new, monospace">$ irb</font></p>
<p><font face="courier new, monospace">irb(main):001:0>
def foo</font></p>
<p><font face="courier new, monospace">irb(main):002:1>
@bar ||= []</font></p>
<p><font face="courier new, monospace">irb(main):003:1>
end</font></p>
<p><font face="courier new, monospace">=>
:foo</font></p>
<p><font face="courier new, monospace">irb(main):004:0>
foo</font></p>
<p><font face="courier new, monospace">=> []</font></p>
<p><font face="courier new, monospace">irb(main):005:0>
foo += []</font></p>
<p><font face="courier new, monospace">NoMethodError:
undefined method `+' for nil:NilClass</font></p>
<p><font face="courier new, monospace"><span> </span>from
(irb):5</font></p>
<p><font face="courier new, monospace"><span> </span>from
/Users/ken/.rbenv/versions/2.1.1/bin/irb:11:in
`<main>'</font></p>
<p><font face="courier new, monospace">irb(main):006:0>
foo</font></p>
<p><font face="courier new, monospace">=> nil</font></p>
</div>
<br>
<fieldset></fieldset>
<br>
</div>
</div>
<div class="">
<pre>_______________________________________________
Chat mailing list
<a moz-do-not-send="true" href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a>
<a moz-do-not-send="true" href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a>
</pre>
</div>
</blockquote>
<br>
</div>
<br>
_______________________________________________<br>
Chat mailing list<br>
<a moz-do-not-send="true"
href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
<a moz-do-not-send="true"
href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org"
target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Chat mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a>
</pre>
</blockquote>
<br>
</body>
</html>