Tagged Questions
0
votes
4answers
26 views
How are properties shared across instances using javascript prototypes
My understanding of prototypical inheritance is every object has a prototype property. If a property doesn't exist on an object then it's prototype object is checked, so on and so on up the chain.
In ...
9
votes
4answers
260 views
Inheritance: object creation
Let's say I have this piece of code:
class Animal {
int legs = 4;
int head = 1;
}
public class Dog extends Animal {
public static void main (String []args) {
Dog dog = new Dog();
...
0
votes
2answers
428 views
Can Ruby subclass instance variables _overwrite_ the superclass's (same name)?
In the Chapter 7.3.5 "Inheritance and Instance Variables" of the book "the ruby programing language" says :
Because instance variables have nothing to do with
inheritance, it follows that an ...
4
votes
3answers
163 views
Instance Variables Inheritance
Can someone explain how a class can access the instance variables of its superclass and how that is not inheritance? I'm talking about 'The Ruby Programming Language' and the example
class Point
...
0
votes
2answers
221 views
how to have access to instance members in a static method
I'm trying to create classes to encapsulate validation and logic for objects like Email , URL , phone number and so on . in the first try I found that I'm repeating the same code in all classes ...
2
votes
5answers
138 views
Instance variable creation in java
If i have the following scenario:
public class Foo extends Baz{
private String banana = "banana";
//blah blah blah
}
public class Baz{
protected static String apple = "apple";
}
Which get ...
0
votes
1answer
237 views
Understanding inheritance of Objective-C instance variables
I would like to extend a method of a superclass A with new functionality by subclassing it in B. Since instance variables default to @protected, accessing them should be fine. However, changes to an ...
4
votes
3answers
721 views
Inherit class-level instance variables in Ruby?
I want a child class to inherit a class-level instance variable from its parent, but I can't seem to figure it out. Basically I'm looking for functionality like this:
class Alpha
...
4
votes
2answers
874 views
Inheriting instance variables in Objective-c
In Objective-c 2.0 why do subclasses need to reference instance variables in parent classes using the self keyword?
Consider this example:
// a.h
@interface MyClass : NSObject
@property (nonatomic, ...
2
votes
1answer
497 views
Ruby: How to set instance variables from a class method?
I'm not sure that's the right title for this question, but I don't know how else to ask it. I have classes that need to be registered globally so they can be called later. I have most of it working ...
0
votes
1answer
365 views
Objective-C: Cast super instance variable in subclass?
In Objective-C, in the definition of a subclass (perhaps in the interface file), is it possible to cast an instance variable (ivar) that's inherited from the super class?
I want to do this because ...
0
votes
1answer
1k views
Java inheritance, anonymous inner class instance member, android callback method
I'm doing this in the context of Android, but my problem is understanding Java. I'm somewhat new to both, so hopefully I'm using the correct terminology here.
I've got a number of sub-classes ...
7
votes
3answers
825 views
Have you ever used a “class instance variable” in any of your Ruby code?
I can understand why you would need a class variable to keep track of things like the total number of objects that have been instantiated in that class.
And I can understand why you would need an ...