Skip to content

Instantly share code, notes, and snippets.

@vquaiato
Created December 14, 2011 02:22
Show Gist options
  • Select an option

  • Save vquaiato/1474942 to your computer and use it in GitHub Desktop.

Select an option

Save vquaiato/1474942 to your computer and use it in GitHub Desktop.
Accessing private instance variables from other objects in Ruby
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