가장 많이 묻는 면접 질문과 답변 & 온라인 테스트
면접 준비, 온라인 테스트, 튜토리얼, 라이브 연습을 위한 학습 플랫폼

집중 학습 경로, 모의고사, 면접 준비 콘텐츠로 실력을 키우세요.

WithoutBook은 주제별 면접 질문, 온라인 연습 테스트, 튜토리얼, 비교 가이드를 하나의 반응형 학습 공간으로 제공합니다.

Chapter 5

Functions, Default Arguments, Lambdas, and Extension Functions

Move from simple statements to reusable logic with functions, named arguments, higher-order functions, lambdas, and one of Kotlin’s signature features: extension functions.

Inside this chapter

  1. Basic Functions
  2. Default and Named Arguments
  3. Lambdas and Higher-Order Functions
  4. Extension Functions
  5. Single-Expression Functions
  6. Real-Time Example

Series navigation

Study the chapters in order for the clearest path from Kotlin setup and syntax to coroutines, backend work, clean design, multiplatform thinking, and advanced engineering practice. Use the navigation at the bottom to move smoothly through the full tutorial series.

Tutorial Home

Chapter 5

Basic Functions

fun add(a: Int, b: Int): Int {
    return a + b
}

Functions are the first step toward clean program structure. They help isolate logic, improve readability, and make testing easier.

Chapter 5

Default and Named Arguments

fun greet(name: String, prefix: String = "Hello"): String {
    return "$prefix, $name"
}

println(greet(name = "Anita"))
println(greet(name = "Anita", prefix = "Welcome"))

This feature reduces overloaded method clutter and makes call sites clearer.

Chapter 5

Lambdas and Higher-Order Functions

val numbers = listOf(1, 2, 3, 4)
val doubled = numbers.map { it * 2 }

Kotlin uses higher-order functions heavily, especially in collections APIs, asynchronous callbacks, builders, and DSL design.

Chapter 5

Extension Functions

fun String.initials(): String {
    return split(" ")
        .filter { it.isNotBlank() }
        .joinToString("") { it.first().uppercase() }
}

println("Riya Sen".initials())

Extension functions allow developers to add utility behavior in a natural way without modifying the original class source. They are common in Android utilities, backend helper modules, and reusable libraries.

Chapter 5

Single-Expression Functions

fun square(x: Int) = x * x

This syntax keeps simple logic concise and readable.

Chapter 5

Real-Time Example

In an online booking platform, functions may validate traveler details, compute fare breakdowns, format itinerary data, and trigger downstream calls. Strong function design prevents business logic from turning into a long unreadable block.

Copyright © 2026, WithoutBook.