November 2017
Beginner
316 pages
6h 40m
English
Till now, we have seen how to use Julia's predefined types as well as user-defined composite types. Now, we are going to delve a little deeper into learning what happens when a user-defined type gets created, and the applications of making this feature more useful to the end user.
As we have already discussed, when we create a new type, we may or may not include field names in the body. Functions, on the other hand, remain distant, and unlike other object-oriented languages, the methods aren't present.
So when we create a new type's object, the default constructor comes into action:
julia> type Family num_members :: Int64 members :: Array{String, 1} endjulia> f1 = Family(2, ["husband", "wife"])Family(2, String["husband", ...Read now
Unlock full access