Created
December 14, 2011 02:22
-
-
Save vquaiato/1474942 to your computer and use it in GitHub Desktop.
Accessing private instance variables from other objects in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| @bar | |
| def initialize(bar) | |
| @bar = bar | |
| end | |
| def are_equal?(foo) | |
| b = foo.instance_variable_get :@bar | |
| b == @bar | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment