I need to know if there is any way to define a new type in Julia that acts like primitive data type, for example:
struct test
att1::MyType
end
Let's suppose that my MyType
is only from 1 to 10. So if I make an instance like this:
test1=test(11)
it should give me an error.
I can guess there is an easier way to do this, but I need to extend MyType more than just from 1 to 10.
The way to define primitive types is described here in the Julia Manual.
In the InlineStrings.jl package you have an excellent demo code here how you can define such types in practice with custom constructors (which I assume you want as I guess you want to perform checking for valid range of arguments when you run the constructor of your type).