Less than sign for inheritance in classes

Hello:

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

class A < B

The < here that is.

Thanks.

On Mar 22, 2010, at 10:07 PM, Smart RoR wrote:

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 W.

Gary W. wrote:

On Mar 22, 2010, at 10:07 PM, Smart RoR wrote:

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 W.

Every operator is a method in ruby…

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

That is my understanding…

On Mar 23, 2010, at 12:05 AM, Smart RoR wrote:

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 W.

Gary W. wrote:

On Mar 23, 2010, at 12:05 AM, Smart RoR wrote:

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 W.

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.

Smart RoR wrote:

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).

On Mar 23, 2010, at 7:46 AM, Smart RoR wrote:

associated method. It looks like an operator


Posted via http://www.ruby-forum.com/.

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 B. http://agileconsultingllc.com
[email protected]

Maybe this wasn’t true in 2010, but today the < method used to evaluate inheritance is defined in the Module class. Class: Module (Ruby 2.5.0)

You can call Kernel.<(BasicObject). It is definitely a method.