May 2019
Beginner to intermediate
466 pages
10h 44m
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