Let's define 4 different classes of points:
type PointType
x
y
end
mutable struct PointMut
x
y
end
immutable PointImmut
x
y
end
struct PointStruct
x
y
end
What is the difference between PointType
and PointMut
? Why would someone choose one over the other?
Also what is the difference between PointImmut
and PointStruct
?
I tend to believe that they are just synonyms, but I didn't find this stated explicitly, so I wonder if there is a subtle difference hidden somewhere.
type
and immutable
are valid up to julia 0.6, mutable struct
and struct
are the names of the same objects in julia 0.6 and forward. mutable
in mutable struct
means that the fields can change - which is actually fairly rarely used so being immutable is the default. mutable struct
's are slower than struct
s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With