[Gambas-user] difference ME and SUPER with inherit

Bruce Steers bsteers4 at gmail.com
Thu Mar 9 19:30:49 CET 2023


On Thu, 9 Mar 2023 at 17:00, Mayost Sharon <sharon at 455.co.il> wrote:

> Hello
>
> first thanks
> I could not understand your explanation
>
> also
> I tried to take the example of the documentation:
> http://gambaswiki.org/wiki/lang/super
> When I run it gives me an error:
> INCORRECT OVERRIDEN IN CLASS
> Attached is an example I tried to run
>

You have much to learn young padwan :)
Overrides are incorrect if they do not match the inherited function.
you must match if it is Static, Public, Private.  you must match the
arguments and the return variable.

The explanation of the difference of Super and Me should be clear.

In the example you linked to in the wiki there is this...

' Reimplements the Add method*Public* *Sub* Add*(*Text *As*
*String**,* Key *As* *String**,* *Optional* Pos *As* *Integer* *=*
-1*)*

  ' Adds the item to the list box  *Super**.*Add*(*Text*,* Pos*)*
  ' Adds the key to key array  *If* Pos *<* 0 *Then*
    $aKey*.*Add*(*Key*)*
  *Else*
    $aKey*.*Add*(*Key*,* Pos*)*
  *Endif*
  $cValue*[*Key*]* *=* Text
*End*

If that method used Me.Add() and not Super.Add() then it would be in
an infinite recursion loop as the local Add() method would just run
itself again.
You do not want that you want to use the Add() method of the inherited
class not your override class.

If you cannot understand the explanation then you will just have to
wait till you figure it out :)  it won't take you long.

Yes there is a very clear difference between Super and Me
Super = Inherited object

Me = local object

BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230309/788a6ec4/attachment.htm>


More information about the User mailing list