You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I mentioned in issue #151, I'm building an UI where the player can choose between selecting a vessel or enter geocoordinates.
This UI is called by a function (let call it select_fn). In the first case, the result has type Vessel and, in the second case, the result has type GeoCoordinates.
Is it even possible to automatically change the type of a function's result?
For now, I have a solution. My select_fn function returns a triple (string, float, float). If the first string is the name of a body, then I know than the 2 other floats are latitude and longitude. In this case, I create a variable of type Geocoordinates.
Else, the string result should be the name of a vessel and the two floats are its geocoordinates. In this case, I can create a variable of type Vessel.
Do you think of an other way to do that?
The text was updated successfully, but these errors were encountered:
At this time, as far as I know, No.
Maybe if this language support fn foobar(param0: T, param1: int) -> T ={} but i'm not even sure it would solve your issue.
The other way is not supported by the language as it is heavily typed, which is good.
Hi,
As I mentioned in issue #151, I'm building an UI where the player can choose between selecting a vessel or enter geocoordinates.
This UI is called by a function (let call it
select_fn
). In the first case, the result has type Vessel and, in the second case, the result has type GeoCoordinates.Is it even possible to automatically change the type of a function's result?
For now, I have a solution. My
select_fn
function returns a triple (string, float, float). If the first string is the name of a body, then I know than the 2 other floats are latitude and longitude. In this case, I create a variable of typeGeocoordinates
.Else, the string result should be the name of a vessel and the two floats are its geocoordinates. In this case, I can create a variable of type
Vessel
.Do you think of an other way to do that?
The text was updated successfully, but these errors were encountered: