Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Featurescript: type checking
jrs_spedley
Member Posts: 71 ✭✭
Just a quickie, I can find an isInteger function and an isReal function (with bounds) but it seems they are more for 'features' rather than programming. Is there a way when parsing an array to check what data type each element is, i.e. isBox, isArray, isString etc?
0
Comments
You can use `is <type>` for this.
Example:
Same syntax as the `is` syntax for typechecking function parameters:
So if you do:
or
you will never actually hit the second block of execution.
To check what builtin type a certain Type is based on you can search the standard library for `export type <TypeYouAreCuriousAbout>`:
Here you can see that a Vector is just an array with nonzero size.
Thanks for super swift response. I'll go and change everything back now as I've just changed all my arrays into boxes as a work around!