[Gambas-user] A little thing about function parameters

Benoit Minisini gambas at ...1...
Sun Nov 23 23:49:55 CET 2008


On dimanche 23 novembre 2008, Fabien Bodard wrote:
> Hi Benoit,
>
> It's a think i've seen since many time..
>
>
>
> 'Class Tmenu
>
> Public sub _New (sText as String, sLink as String, OPTIONAL hParent as
> Tmenu, OPTIONAL aAutoSelect as String[])
>
>   Text = sText
>   {Link} = sLink
>
>   IF aAutoSections.Exist(Request["section"]) THEN ME.IsSelected = TRUE
>
>   IF NOT IsNull(hParent) THEN hParent.Children.Add(ME)
>
> End
>
> Well, the problem is i can't call this by this way
>
>
>     Dim hMenu as Tmenu
>
>     hMenu = NEW Tmenu("Sommaire", "/",, ["index"])
>
> I need in fact write this :
>
>     hMenu = NEW Tmenu("Sommaire", "/", NULL, ["index"])
>
>
> in VB it is possible and the both are simple to read i think.
>
> Why the compiler does not take care about that ?
>
> Best regards,
>
> Fabien Bodard
>

You do not have to specify optional arguments, unless when using the NEW 
keyword. I don't remember at the moment if there is a good reason for that 
limitation. I will investigate...

Regards,


-- 
Benoit Minisini




More information about the User mailing list