Maybe we can have a function that returns possibly multiple types, what do you think no #1202
Replies: 4 comments 4 replies
-
Are you referring to having |
Beta Was this translation helpful? Give feedback.
-
In other worlds, you can specialize the function with type parameter therefore the template produce different functions that returns different things |
Beta Was this translation helpful? Give feedback.
-
In other words, only when you use a DU case constructor - basically a constant. At that point you might as well create |
Beta Was this translation helpful? Give feedback.
-
Perhaps casting it into object is acceptable.. maybe in the end that's the solution that people had the foresight back in the day |
Beta Was this translation helpful? Give feedback.
-
Our program is powering the real world machines that's processing fruits, depending on what you want, it either gives you meat or juice.
A program is like a function, in which you ask it to do something then it gives you a result, irl the result is usually multiple types.
You can say that it's all the 0 and 1 and sort of the same, you can say that regardless of whether a function returning an integer or a string it's gonna be treated the same as paints on the GUI, however for the better of living in an imaginary world we think meat and juice is different thing.
we can prove they are different :
we can prove that the function returns a string when the type of the argument 'want' is known at the call site at compile time, you can't use this function without saying if you want meat or juice
Beta Was this translation helpful? Give feedback.
All reactions