Orta Düzey Julia
Anthony Markham
Quantitative Developer
struct anahtar sözcüğünü kullanın.struct içindeki her alan, bildirim içinde girintilenir.struct Person
age
height
location
end
steve = Person(18, 180, "London")
println(steve.height)
180
steve'in türü Person'dır.struct Person
age
height
location
end
steve = Person(18, 180, "London")
println(typeof(steve))
Person
# Steve'in doğum günü!
steve = Person(18, 180, "London")
steve.age = 19
setfield!: Person türündeki değişmez yapı değiştirilemez
mutable anahtar sözcüğünü kullanın.mutable struct Person
age
height
location
end
steve = Person(18, 180, "London")
steve.age = 19
println(steve)
Person(19, 180, "London")
mutable struct Person
age::Int64
height::Int64
location::String
end
steve = Person(18.5, 180, "London")
InexactError: Int64(18.5)
Orta Düzey Julia