less than sign for inheritance in classes

S

Smart RoR

Hello:

Where in Ruby is the less than sign for inheritance in classes defined?

class A < B


The < here that is.


Thanks.
 
G

Gary Wright

Where in Ruby is the less than sign for inheritance in classes defined?

class A < B

I'm not sure if I understand your question, but '<' is just syntax when
used in a class definition. In this context, it is not an operator and so
there is no method associated with its use in this context.

Gary Wright
 
S

Smart RoR

Gary said:
I'm not sure if I understand your question, but '<' is just syntax when
used in a class definition. In this context, it is not an operator and
so
there is no method associated with its use in this context.

Gary Wright

Every operator is a method in ruby....

like 1 - 1 = 0 here - is a method.

That is my understanding....
 
A

Albert Schlef

Smart said:
Every operator is a method in ruby....

like 1 - 1 = 0 here - is a method.

That is my understanding....

And is the "=" too a method? Can you redefine it?
Where in Ruby is the less than sign for inheritance
in classes defined?

If you want to find out if somebody is inheriting your class, implement
'MyClass.inherited' (it's a hook).
 
G

Gary Wright

Every operator is a method in ruby....

like 1 - 1 = 0 here - is a method.

That is my understanding....

Let me try again. The '<' in a class definition
is not an operator and so doesn't have an
associated method. It looks like an operator
but is not parsed or interpreted as an operator
when used in a class definition.

Gary Wright
 
S

Smart RoR

Gary said:
Let me try again. The '<' in a class definition
is not an operator and so doesn't have an
associated method. It looks like an operator
but is not parsed or interpreted as an operator
when used in a class definition.

Gary Wright


Thanks. But in that case where is the < handled to identify
inheritance....
That is the core handling as to where is this implemented in ruby core.
 
R

Rob Biedenharn

Thanks. But in that case where is the < handled to identify
inheritance....
That is the core handling as to where is this implemented in ruby
core.


That would be deep inside parse.y -- the grammar file for the parser.
Look for the superclass non-terminal (about 4100 lines or so into the
file).

-Rob

Rob Biedenharn http://agileconsultingllc.com
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top