Funny doc for setter

Is it just me or is this funny?

------------------------------------------- Object#instance_variable_set
      obj.instance_variable_set(symbol, obj) => obj

···

------------------------------------------------------------------------
      Sets the instance variable names by _symbol_ to _object_, thereby
      frustrating the efforts of the class's author to attempt to provide
      proper encapsulation. The variable did not have to exist prior to
      this call.

I see the same subtle humor here :slight_smile:

Robert

···

On 5/5/07, John Joyce <dangerwillrobinsondanger@gmail.com> wrote:

Is it just me or is this funny?

Yeah, but it doesn't expose anything that didn't already exist in Ruby.
If the function didn't exist, you could write it yourself:

class Object
  def instance_variable_set symbol, obj
    eval "@#{symbol}=obj"
  end
end

--Ken

···

On Sun, 06 May 2007 01:56:18 +0900, John Joyce wrote:

Is it just me or is this funny?

------------------------------------------- Object#instance_variable_set
      obj.instance_variable_set(symbol, obj) => obj
------------------------------------------------------------------------
      Sets the instance variable names by _symbol_ to _object_, thereby
      frustrating the efforts of the class's author to attempt to
provide
      proper encapsulation. The variable did not have to exist prior to
      this call.

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/

Ahh, but it's a subtle reminder that even if something is possible one
shouldn't always do it, at least without thought to the consequences.

···

On 5/8/07, Ken Bloom <kbloom@gmail.com> wrote:

On Sun, 06 May 2007 01:56:18 +0900, John Joyce wrote:

> Is it just me or is this funny?
>
> ------------------------------------------- Object#instance_variable_set
> obj.instance_variable_set(symbol, obj) => obj
> ------------------------------------------------------------------------
> Sets the instance variable names by _symbol_ to _object_, thereby
> frustrating the efforts of the class's author to attempt to
> provide
> proper encapsulation. The variable did not have to exist prior to
> this call.

Yeah, but it doesn't expose anything that didn't already exist in Ruby.
If the function didn't exist, you could write it yourself:

class Object
  def instance_variable_set symbol, obj
    eval "@#{symbol}=obj"
  end
end

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/