Top "Instance-variables" questions

In object-oriented programming with classes, an instance variable is a variable defined in a class (i.e. a member variable), for which each object of the class has a separate copy.

Access instance variable from outside the class

If an instance variable belongs to a class, can I access the instance variable (e.g. @hello) directly using the …

ruby instance-variables
How can I initialize a module's instance variables in Ruby?

I have some modules where I would like to use instance variables in. I'm currently initializing them like this: module …

ruby module instance-variables
Why are instance variables in Java always private?

I'm newbie to Java and I'm learning about encapsulation and saw an example where instance variables are declared as private …

java instance-variables
Visual C# - Access instance of object created in one class in another

I apologize in advance with what will probably be a fairly easy/quick answer based on scope, but I've looked …

c# instance-variables
How to make a real private instance variable?

I want to make an instance variable that can't be accessed from outside. Is something like that possible in objective-c? …

objective-c private visibility instance-variables
Ruby Metaprogramming: dynamic instance variable names

Let's say I have the following hash: { :foo => 'bar', :baz => 'qux' } How could I dynamically set the keys …

ruby metaprogramming instance-variables
Ruby Rspec : Testing instance variables without adding an accessor to source

I'm trying to test the following method: def unprocess_move(board, move) if move[0].instance_of?(Array) multi_move = @multi_…

ruby rspec instance-variables
How to deal with Pylint's "too-many-instance-attributes" message?

I have just tried to lint some code with Pylint, and the last remaining error is R0902: too-many-instance-attributes (8/7) I understand …

python instance-variables pylint code-readability code-structure
How to make instance variables private in Ruby?

Is there any way to make instance variables "private"(C++ or Java definition) in ruby? In other words I want …

ruby instance-variables private-members
When do Ruby instance variables get set?

class Hello @hello = "hello" def display puts @hello end end h = Hello.new h.display I created the class above. …

ruby syntax instance-variables