Julia 중급
Anthony Markham
Quantitative Developer
struct 키워드로 구조체를 정의합니다.struct 선언 내부에 들여쓰기 합니다.struct Person
age
height
location
end
steve = Person(18, 180, "London")
println(steve.height)
180
steve의 타입은 Person입니다.struct Person
age
height
location
end
steve = Person(18, 180, "London")
println(typeof(steve))
Person
# Steve의 생일!
steve = Person(18, 180, "London")
steve.age = 19
setfield!: immutable struct of type Person cannot be changed
mutable 키워드로 변경 가능한 구조체를 만듭니다.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)
Julia 중급