Check types
How to check a type of a variable?
raises an error
also raises an error
I was only able to print the types using:
However it seems to be not possible to return the type instead of just printing it
6 Replies
for your struct type is the variable you are passing in so you would have to call that if you want it to return from your type printing struct. If you are trying to return the Int type so you can use it somewhere else that won't work as types have to be compile time static. AnyType is a type which can be used as a placeholder for different types but it does not encompass types themselves as returns.
I think the thing you are trying to do is blocked by traits.
I see
I am looking for a direct way to do somthing like this
which is in python:
Until we get enums and/or the ability to create generic types you literally just have to write overloads for every type of input you want. However you can use the fact that all the scalar types are simd and simd's have casting ability for example.
when inside of a struct that defines dtype will cast any numerical value (except bools and maybe index) to the dtype specified on creation of the struct.
For the purpose of being able to
a*=b
where a is an has a defined type and b is any scalar numeric.I see. Thanks