struct Sample {
// 가변 프로퍼티
var mutableProperty: Int = 100
// 불변 프로퍼티
let immutableProperty: Int = 100
// 타입 프로퍼티
static var typeProperty: Int = 100
// 인스턴스 메서드
func instanceMethod() {
print("instance method")
}
// 타입 메서드
static func typeMethod() {
print("type method")
}
}
타입 프로퍼티 예제
var mutable: Sample = Sample() // 타입 프로퍼티 및 메서드 Sample.typeProperty = 300 Sample.typeMethod() // type method // 인스턴스에서는 타입 프로퍼티나 타입 메서드를 // 사용할 수 없습니다 // 컴파일 오류 발생 // //mutable.typeProperty = 400 //mutable.typeMethod()