[Gambas-user] Optional and Param (Gambas 3)
Werner
wdahn at ...1000...
Thu Jun 10 08:37:16 CEST 2010
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
More information about the User
mailing list