Ruby Help


#1

Can an instance method access the value of a local variable defined in another instance method? Can it access the value of an instance variable defined in another instance method?

How do you give a class access to the methods defined in a mixin?

Can a class have more than one ‘child’ through inheritance? Can a class have more than one ‘parent’ through inheritance?

What is a class's public interface?

When an object is sent a message, how does method look up work? What does the compiler do?

If you can't answer all of those questions, I would appreciate if you can answer one or a couple. Thanks!


#2

In short, no. Because the local variable is scoped to its own instance/method. To make it a shared variable, it could defined as a class variable, then all the methods and instances can access it.

Inheritance is a chain. A super class can be inherited by any number of other classes, but a class can only inherit from one parent class. This class may also be a parent class to another class, which would by inheritance, inherit that parent's parent class in the process. This is where the chain comes in.

Sorry I can't quickly come up with an example, but did find you some extra reading:

http://rubylearning.com/satishtalim/ruby_inheritance.html


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.