Kotlin - Properties


Kotlin - Properties

Kotlin - Properties // 클래스를 이용한 properties 선언 class Address { var name: String = "Holmes, Sherlock" var street: String = "Baker" var city: String = "London" var state: String? = null var zip: String = "123456" } // properties 참조하는 방법 fun copyAddress(address: Address): Address { val result = Address() // there's no 'new' keyword in Kotlin result.name = address.name // accessors are called result.street = address.street // ... return result } - properties(속성)사용할 때 보통 속성이름에 맞춰 값을 설정하는데, 그 방법은 되게 다양...


#Kotlin #Kotlin_backing_field #Kotlin_Properties

원문링크 : Kotlin - Properties