[Gambas-user] Optional and Param (Gambas 3)
Charlie Reinl
Karl.Reinl at ...2345...
Thu Jun 10 09:38:03 CEST 2010
Am Donnerstag, den 10.06.2010, 14:37 +0800 schrieb Werner:
> I'm trying to implement a simple class that creates a Float[3] array. I
> would like to give the user of the class an optional opportunity to fill
> the array with data when the class is instantiated.
>
> ----------------------------------------
> ' Gambas class file
> ' Vector3f Class
>
> Public v As New Float[3]
>
> Public Sub _new(Optional x As Float, y As Float, z As Float)
> If Param.Count > 0 Then v[0] = x
> If Param.Count > 1 Then v[1] = y
> If Param.Count > 2 Then v[2] = z
> End
> ---------------------------------------
>
> The above does not work because Param.Count is always 0 no matter if
> parameter values are supplied or not. My guess is that's because
> Optional can only be used from the second parameter onwards (why?).
>
> How can I make this class do what it should?
>
> Thanks
> Werner Dahn
Salut Werner,
where Param is filled? , what is Param ? an array? the class ?
for Optional, I do not know if it can be chained like you do.
But it can be used also on the first Parameter.
--
Amicalement
Charlie
More information about the User
mailing list