[Gambas-user] difference ME and SUPER with inherit
Mayost Sharon
sharon at 455.co.il
Thu Mar 9 20:05:30 CET 2023
Hello
Yes I am this Gambas-user
To learn from you
But when I try to run the sample it gives an error
(I am attaching the sample file "super2.tar.xz" again) for me it gives an error
Can you fix the error for me?
And so I can study well
You helped me a lot when you wrote "recursion loop"
If I understood correctly, in the "Clear" part of the example it doesn't matter if we use ME or SUPER
' Reimplements the Clear method
public Sub Clear()
Super.Clear
$aKey.Clear
$cValue.Clear
End
Many thanks again to all the helpers
---------- Original Message -----------
From: Bruce Steers <bsteers4 at gmail.com>
To: Gambas Mailing List <user at lists.gambas-basic.org>
Sent: Thu, 9 Mar 2023 18:30:49 +0000
Subject: Re: [Gambas-user] difference ME and SUPER with inherit
> 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
------- End of Original Message -------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: super2.tar.xz
Type: application/x-xz
Size: 12860 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230309/7ce4e9f9/attachment.xz>
More information about the User
mailing list