1
$\begingroup$

As the title says, I am asking myself is there is a specific function which returns the type of something. Ideally, I would work as follows :

let a = 4.0;
Message(Type(a));

This would print :

double

Is there anything similar to this ? I tried to look at the api, but didn't find anything, I could definitely have missed something there.

$\endgroup$

1 Answer 1

4
$\begingroup$

No, there isn't. We are avoiding having the means for types to impact the program flow, but I'd be interested to hear what the use case is. If is it only a matter of wanting to print the type rather than getting something that can be used within the program, then that is certainly something we could cover in the future (please consider making a feature request).

$\endgroup$
5
  • 1
    $\begingroup$ Honnestly, its only for "debuging", I am trying to understand why I am passing the wrong type in the arguments for an operation but I am failing miserably. $\endgroup$ Commented Aug 5, 2020 at 20:06
  • $\begingroup$ Yes, I can see how that would be useful. What environment are you working with, notebooks? In VS or VS Code you would get type information as part of hovering over a variable or expression. $\endgroup$ Commented Aug 5, 2020 at 23:04
  • $\begingroup$ VS code, I actually saw the hover information right after writting this $\endgroup$ Commented Aug 6, 2020 at 12:59
  • $\begingroup$ @Jonathcraft Cool! Was it informative or do you have any suggestion what could be made more clear there? $\endgroup$ Commented Aug 6, 2020 at 21:16
  • $\begingroup$ I realised the problem was that the input was incorrect, but it helped when I checked that everything was fine. I am still getting used to the errors. The only thing that could be better is the line at which the error is (it always says line 0) $\endgroup$ Commented Aug 7, 2020 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.