December 2018
Beginner to intermediate
500 pages
12h 10m
English
It is also possible (and equally easy) to construct mutable composite types. The only thing we need to do is to use the mutable struct statement, instead of just struct:
julia> mutable struct Player
username::String
score::Int
end
Our Player object should be mutable, as we'll need to update the score property after each game:
julia> me = Player("adrian", 0)
Player("adrian", 0)
julia> me.score += 10
10
julia> me
Player("adrian", 10)
Read now
Unlock full access