Skip to content

Instantly share code, notes, and snippets.

@yangsu
Created January 28, 2013 03:48
Show Gist options
  • Save yangsu/4652873 to your computer and use it in GitHub Desktop.
Save yangsu/4652873 to your computer and use it in GitHub Desktop.
Ruby Variable Encapsulation
class Base
def initialize()
@x = 10
end
end
d = Base.new
puts d.x # => undefined method `x' for ... (NoMethodError)
puts d.instance_variable_get :@x # => 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment