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.

Must all Python instance variables be declared in def __init__?

Or can they be declared otherwise? The code below does not work: class BinaryNode(): self.parent = None self.left_child = …

python instance-variables
Local variables set to nil? (Objective-C)

I'm reading a book on Objective-C and the author said that if local variables aren't assigned a value they will …

objective-c instance-variables null static-variables
"Access of shared member, constant member, enum member or nested type through an instance"

I wonder why Visual Studio is raising this warning: Access of shared member, constant member, enum member or nested type …

.net vb.net warnings shared instance-variables
Directly accessing an instance variable vs. Using an accessor method

Can anyone explain the difference between accessing an instance attribute via self.attribute and by @attribute?

ruby instance-variables accessor
CoffeeScript instance variable

I'm learning CoffeeScript, and I've got one minor headache I haven't quite been able to figure out. If I create …

coffeescript instance-variables
Should I declare variables in interface or using property in objective-c arc?

approach 1: @interface MyController : UIViewController { UILabel *myText; } @property (nonatomic, strong) UILabel *myText; approach 2: @interface MyController : UIViewController @property (nonatomic, strong) UILabel *myText; …

ios objective-c automatic-ref-counting instance-variables
What is the correct (or best) way to subclass the Python set class, adding a new instance variable?

I'm implementing an object that is almost identical to a set, but requires an extra instance variable, so I am …

python subclass set instance-variables
Instance variables in methods outside the constructor (Python) -- why and how?

My questions concern instance variables that are initialized in methods outside the class constructor. This is for Python. I'll first …

python class constructor instance-variables
What exactly does "static" mean when declaring "global" variables in Java?

I've been running into this problem many times and I never bothered to learn why its happening and learn what "…

java class static instance-variables static-variables
Same instance variable for all actions of a controller

I have a rails controller with two actions defined: index and show. I have an instance variable defined in index …

ruby-on-rails ruby scope instance-variables