Private variables can be changed outsid e? 
Author Message
 Private variables can be changed outsid e?

Quote:
> 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.

Quote:
> 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



Mon, 23 Dec 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Private variables can be changed outside?

2. cross-version voodoo: handling 8.3 / 8.4 private structure changes

3. Changing environment variables into python variables

4. PRIVATE variables (was parameters)

5. Lots of Public and Private variables - no penalties on modern PC.

6. Public\private memory variables

7. Making Instace Variables Private/Local

8. Private instance variables

9. private variables

10. private variables (again)

11. private variable

12. cant see PRIVATE variable in MODULE SUBROUTINE when debugging with IFC/IDB v7.1

 

 
Powered by phpBB® Forum Software