less than 1 minute read

코틀린에서 함수의 파라미터는 val, 즉 상수(불변) 값이다. 이렇게 만든 이유는 아래와 같다고 한다.

사용자들이 함수 파라미터를 pass by reference 로 혼동함(코틀린에서는 pass by reference 미지원, pass by value만 지원) 파라미터 값을 변경하는 것은 좋은 코딩 습관이 아님.

In the Kotlin, Function parameters are val(Immutable). The reasons why are,

People confused function parameters are “pass by reference”. (Kotlin is not supported “pass by reference”, only support “pass by value”) mutating parameters is no good coding style.

[Reference]

  • https://blog.jetbrains.com/kotlin/2013/02/kotlin-m5-1/