[Gambas-user] Method overloading in Gambas

Benoît Minisini gambas at ...1...
Thu Feb 5 16:58:53 CET 2009


> Hello Benoît,
>
> On Thu, 5 Feb 2009 16:35:53 +0100, Benoît Minisini wrote:
> > It is impossible to implement this kind of method overloading in Gambas.
> >
> > [..]
>
> Ok, understood.
>
> I probably found a trick, posting it here so that people looking at the
> archives can find it :)
>
> I'm working (yes, still) on a gb.net.ldap component, and needed this
> "overloading" thing. I solved it using a Module called "LDAP" (-> static),
> and a class called LDAPConnection. How to use:
>
> ---8<---
> ldap AS NEW LDAPConnection
>
> ldap.Host = ".."
> ldap.Port = ".."
> [..]
> ldap.Connect()
> --->8---
>
> LDAPConnection has:
>
> ---8<---
> PUBLIC SUB Connect()
>     LDAP.Connect(ME.sHost, ME.iPort, [..])
> END
> --->8---
>
> And LDAP.Connect() has the right signature and code doing stuff. Obviously
> one could also call LDAP.Connect() directly.
>
> Back to code now!
>
> Ciao,
> David

You can use optional arguments to replace method overloading.

-- 
Benoît




More information about the User mailing list