[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03858] Re: Private variables can be changed outsid e?

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-07-06 08:46:37 UTC
List: ruby-talk #3858
> Ruby doesn't guarantee that you can't poke around inside an object or
> class. In fact, quite the reverse--it provides many mechanisms to let
> you do just that.

Yep, this was about the conclusion I came during the night.

> However, I hadn't realized that you could do the trick with
> late-binding instance variables. 

Well, me neither :). But if I reflect OO-things from C++ or Java I think
they don't allow parent class to know the real class is actually a child
when calling.

class Foo
  def foo
	p self.type
  end
end

class Bar < Foo
end

Bar.new.foo

In those languages call to Bar.new.foo forces Foo#foo to think self is
actually an object of type Foo, not kind_of? Foo. This was the surprise.

	- Aleksi

In This Thread

Prev Next