Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backing Field & Property (Kotlin 프로퍼티) #38

Open
SuyeonChoi opened this issue Nov 25, 2022 · 0 comments
Open

Backing Field & Property (Kotlin 프로퍼티) #38

SuyeonChoi opened this issue Nov 25, 2022 · 0 comments

Comments

@SuyeonChoi
Copy link
Owner

  • 프로퍼티
    • val, var
    • 필드와 accessor 메서드를 자동으로 생성해주는 문법
  • Backing Fields(뒷받침하는 필드)
    • 커스텀 getter, setter에서 사용. 접근자 내부에서 field에 접근할 때 사용
      • getter에서는 field값을 읽기만 할 수 있고, setter에서는 field값을 읽고 쓰기 가능
    • 코틀린 클래스에서는 직접적으로 필드를 선언할 수 없다. 값을 저장하는 동시에 로직을 실행할 수 있게 하기 위해서는 접근자 안에서 프로퍼티를 뒷받침하는 필드가 있어야한다.
    • field 지시자를 통해 게터나 세터에서 사용
  • Backing Property(뒷받침하는 프로퍼티)
    • Backing fields 체계에 맞지 않는 작업을 수행할 경우 Backing properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant