From: dblack@... Date: 2006-03-29T00:56:25+09:00 Subject: Re: Why do some methods names which replace the content in place doesn't have the "!" sign? Hi -- On Wed, 29 Mar 2006, Gregory Seidman wrote: > On Wed, Mar 29, 2006 at 12:00:32AM +0900, dblack@wobblini.net wrote: > } On Tue, 28 Mar 2006, Robert Dober wrote: > } >and how can one modify a receiver without modifying its instance variables, > } > } str = "hello" > } str.replace("goodbye") > } > } I've changed str without any instance variables being involved. Same > } with: > } > } array = [1,2,3] > } array.pop > } > } and so forth. > > It's a technicality. Consider strings. Their internals are under the hood, > so you claim that no instance variables are involved. This is not > technically accurate. Object state happens to be held in C variables rather > than Ruby variables (which are, of course, backed by C variables), but they > are most certainly instance variables. Are you trolling or do you actually > believe you are right? I've been using Usenet since 1990 and never trolled. I'm not going to start now. I'm talking about Ruby, not C. In Ruby, you can modify a receiver without changing its instance variables -- in fact, you can modify a receiver that doesn't *have* any instance variables. irb(main):001:0> s = "" => "" irb(main):002:0> s.replace("abc") => "abc" irb(main):003:0> s.instance_variables => [] The term "instance variable" has a specific and unambiguous meaning in Ruby. David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black