[Kotlin] Local Functions λ‘컬 ν¨μ
μΆμ²
https://kotlintutorial.io/local-functions-in-kotlin/
Local functions in Kotlin
In Kotlin there are local functions that can be defined within a larger function. These functions are only visible within this larger function and cannot be accessed from outside. Local functions have the advantage of making code more readable and clear by
kotlintutorial.io
ChatGPT
https://cornswrold.tistory.com/464
[Kotlin] μ½νλ¦° λ‘컬ν¨μμ νμ₯
μ½νλ¦°μμλ ν¨μμμ μΆμΆν ν¨μλ₯Ό μ ν¨μ λ΄λΆμ μ€μ²©μν¬ μ μλ€. κ·Έλ κ² νλ©΄ λ¬Έλ²μ μΈ λΆκ° λΉμ©μ λ€μ΄μ§ μκ³ κΉλνκ² μ½λλ₯Ό μ‘°μ§ν μ μλ€. (DRY. Don't Repeat Yourself) νν λ°μνλ
cornswrold.tistory.com
https://realkotlin.com/tutorials/2018-06-12-local-functions-in-kotlin/
Local functions in Kotlin
Kotlin supports local functions, i.e. it allows you to put a function inside a function.
realkotlin.com
λ‘컬 ν¨μ Local Functions
ν¨μ μμ μ μλ ν¨μ. μΈλΆ ν¨μ μμμλ§ λ³Ό μ μκ³ , κ·Έ μΈλΆμμλ μ κ·Όμ΄ λΆκ°λ₯νλ€.
λ‘컬 ν¨μμ λͺ©μ
1. λ‘μ§ μΊ‘μν
λ‘컬 ν¨μλ μΈλΆ ν¨μ μμμ μ μ μλκ³ νΉνν μμ μ μνν¨μΌλ‘μ¨ λ‘μ§μ μΊ‘μννλ€.
2. κ°λ μ±
νΉμ λͺ©μ λ¬μ±μ μν΄ λͺ ννκ² μ μλ λ‘컬 ν¨μλ₯Ό λ§λ€μ΄ μ½λ κ°λ μ±μ΄ ν₯μλλ€.
3. μ¬μ¬μ©μ±
μ½λ μ€λ³΅ μμ΄ μΈλΆ ν¨μ μμμ μ¬μ¬μ©μ΄ κ°λ₯νλ€. μ€λ₯ μμ€λ₯Ό μ€μ΄κ³ λ μΌκ΄λκ³ μ μ§λ³΄μ κ°λ₯ν μ½λλ₯Ό λ§λ λ€.
4. ν¨μ μ£Όμμ 컨ν μ€μ μ κ·Ό
λ‘컬 ν¨μλ μΈλΆ ν¨μμ 맀κ°λ³μμ λ³μμ μ κ·Όν μ μλ€. μ΄λ₯Ό ν΅ν΄ λ‘컬 ν¨μμ 컨ν μ€νΈ κ°μ μνΈμμ©μ΄ κ°λ₯ν΄μ λ‘컬 ν¨μμ μΆκ° 맀κ°λ³μλ₯Ό μ λ¬νμ§ μμλ λλ€.
λ‘컬 ν¨μλ λ©μλ μΆμΆ 리ν©ν λ§μμλ³΄λ€ λ ν¨μ¨μ μΌλ‘ μ½λλ₯Ό κ΄λ¦¬νκ³ λΆνμν μ€λ³΅μ λ°©μ§ν μ μλ€.
λ©μλ μΆμΆ 리ν©ν λ§μμ μ’ μ’ λ°μνλ λΆνμν μ½λλ₯Ό μ€μΌ μ μλ λ°©λ² μ€ νλκ° λ‘컬 ν¨μμ μ¬μ©μ΄λ€.
λ©μλ μΆμΆ 리ν©ν λ§μ ν΅ν΄ μ½λλ₯Ό λ μμ λ¨μλ‘ λλ λ, μΈλΆ ν΄λμ€λ λ΄λΆ ν΄λμ€, νμΌλ‘ ν¨μλ₯Ό λΆλ¦¬νλ λμ ν΄λΉ ν¨μ λ΄λΆμμλ§ μ¬μ©λλ λ‘μ§μ΄λΌλ©΄ λ‘컬 ν¨μλ‘ μ μν μ μλ€. μ΄λ κ² νλ©΄ μ½λκ° λ κΉλνκ³ λΆνμνκ² λ§μ λ©μλλ₯Ό ν΄λμ€λ νμΌμ μΆκ°ν νμκ° μλ€.
μ
https://cornswrold.tistory.com/464
[Kotlin] μ½νλ¦° λ‘컬ν¨μμ νμ₯
μ½νλ¦°μμλ ν¨μμμ μΆμΆν ν¨μλ₯Ό μ ν¨μ λ΄λΆμ μ€μ²©μν¬ μ μλ€. κ·Έλ κ² νλ©΄ λ¬Έλ²μ μΈ λΆκ° λΉμ©μ λ€μ΄μ§ μκ³ κΉλνκ² μ½λλ₯Ό μ‘°μ§ν μ μλ€. (DRY. Don't Repeat Yourself) νν λ°μνλ
cornswrold.tistory.com
https://realkotlin.com/tutorials/2018-06-12-local-functions-in-kotlin/
Local functions in Kotlin
Kotlin supports local functions, i.e. it allows you to put a function inside a function.
realkotlin.com