less than sign for inheritance in classes

Discussion in 'Ruby' started by Smart RoR, Mar 23, 2010.

  1. Smart RoR

    Smart RoR Guest

    Hello:

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

    class A < B


    The < here that is.


    Thanks.
    --
    Posted via http://www.ruby-forum.com/.
    Smart RoR, Mar 23, 2010
    #1
    1. Advertising

  2. Smart RoR

    Gary Wright Guest

    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 Wright
    Gary Wright, Mar 23, 2010
    #2
    1. Advertising

  3. Smart RoR

    Smart RoR Guest

    Gary Wright 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 Wright


    Every operator is a method in ruby....

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

    That is my understanding....

    --
    Posted via http://www.ruby-forum.com/.
    Smart RoR, Mar 23, 2010
    #3
  4. 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).
    --
    Posted via http://www.ruby-forum.com/.
    Albert Schlef, Mar 23, 2010
    #4
  5. Smart RoR

    Gary Wright Guest

    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 Wright
    Gary Wright, Mar 23, 2010
    #5
  6. Smart RoR

    Smart RoR Guest

    Gary Wright 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 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.

    --
    Posted via http://www.ruby-forum.com/.
    Smart RoR, Mar 23, 2010
    #6
  7. On Mar 23, 2010, at 7:46 AM, Smart RoR wrote:

    > Gary Wright 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 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.
    >
    > --
    > 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 Biedenharn http://agileconsultingllc.com
    Rob Biedenharn, Mar 23, 2010
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. falcon
    Replies:
    10
    Views:
    18,656
    Roedy Green
    Feb 24, 2006
  2. Graeter than or less than

    , Jun 21, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    860
    bruce barker
    Jun 21, 2007
  3. jiajia wu
    Replies:
    0
    Views:
    355
    jiajia wu
    Oct 1, 2009
  4. Dwight Army of Champions
    Replies:
    4
    Views:
    2,749
    John H.
    Mar 17, 2010
  5. J.D. Buehls
    Replies:
    2
    Views:
    139
    J.D. Buehls
    Jun 16, 2004
Loading...

Share This Page