Reputation: 3
Julia programming language has a very strong structure and usage for datatypes. I have read the original documentation of Julia but I didn't understand the 'defining a datatype' part. How can I use the datatype which is defined by me? For example
abstract type newType
end
datatype(a::newType) = return a
datatype(12)
results in
ERROR: MethodError: no method matching datatype(::Int64)
Closest candidates are:
datatype(::newType) at REPL[5]:1```
Upvotes: 0
Views: 106
Reputation: 6378
You're basic problem is that you can not instantiate an abstract type in Julia, only a concrete subtype. For example, you can not make a Number
, but instead can make an Int
or a Float
(which are types of Number
s).
Upvotes: 1