From: Paul Brannan Date: 2002-05-21T22:48:59+09:00 Subject: Re: Memory consumption. On Tue, May 21, 2002 at 10:28:17PM +0900, Yohanes Santoso wrote: > That means you have to be careful not to do too much > a = "foo" + "bar" > instead > a = "#{foo}#{bar}" This isn't quite the same thing. One is: a = "foo" + "bar" #=> a == "foobar" the other is: a = foo + bar #=> a == ? I think that: a = "foo" "bar" and a = "foo" \ "bar" also avoid the intermediate objects, though, if the former is really what you meant. It's interesting to see how the Pragmatic Programmers' node dumper prints each of these: [pbrannan@zaphod pbrannan]$ ruby -rNodeDump -e '"foo" + "bar"' NodeDump V0.1.4 NODE_NEWLINE: [-e:1] NODE_CALL: to method: 43 (+) Receiver: NODE_STR: "foo" Parameters: NODE_ARRAY: size = 1 NODE_STR: "bar" [pbrannan@zaphod pbrannan]$ ruby -rNodeDump -e '"#{foo}#{bar}"' NodeDump V0.1.4 NODE_NEWLINE: [-e:1] NODE_DSTR: "" NODE_EVSTR: "foo" NODE_EVSTR: "bar" [pbrannan@zaphod pbrannan]$ ruby -rNodeDump -e 'foo + bar' NodeDump V0.1.4 NODE_NEWLINE: [-e:1] NODE_CALL: to method: 43 (+) Receiver: NODE_VCALL: self.foo Parameters: NODE_ARRAY: size = 1 NODE_VCALL: self.bar [pbrannan@zaphod pbrannan]$ ruby -rNodeDump -e '"foo" "bar"' NodeDump V0.1.4 NODE_NEWLINE: [-e:1] NODE_STR: "foobar" Paul