November 2017
Beginner
316 pages
6h 40m
English
As we know from the starting chapters that Julia supports multiple dispatch and we can create a new data type from any abstract data type, let's define a new type, named Student, and then create two sample objects for this type:
julia> type Student
name::String
age::Int64
end
julia> alpha = Student("alpha",24)
Student("alpha", 24)
julia> beta = Student("beta",25)
Student("beta", 25)
Pretty simple! Now that we have two of these students, with the names alpha and beta, how can I be sure of which type they are? You should definitely be thinking of a function that we studied earlier, remember? If not, then let's look at the following example for the answer:
julia> typeof(alpha) Student julia> typeof(beta) Student
Ah, the
Read now
Unlock full access