[Gambas-user] difference ME and SUPER with inherit

Bruce Steers bsteers4 at gmail.com
Thu Mar 9 21:12:28 CET 2023


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

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

Aaah It seems the example in the wiki is wrong :-\

Like I said you must match the arguments
the example adds a "Key" arg to the Add method and that is wrong.


And it seems you did not understand at all.
if you run Me.Clear() in the classes Clear() method it will loop ,
Me.Clear() IS Clear()

Public Sub Clear()
  Me.Clear()
End

Is the same as,,,
Public Sub Clear()
  Clear()
End

You must understand..
The class has inherited another class so it has all it's properties/methods
by default. (Me.)
Any properties/methods you are *NOT* overriding you can use Me.
you will see the inherited classes objects.

if you *HAVE* made your own override for a property/method then using Me.
will be your own override not the inherited class. You will use Super. to
access the inherited objects.

Does that make sense?
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230309/84889233/attachment-0001.htm>


More information about the User mailing list