Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pattern Matching

Basic Match

맞춤 값 {
    1 => 출력("하나")
    2 => 출력("둘")
    _ => 출력("기타")
}

With Blocks

맞춤 상태 {
    "활성" => {
        출력("활성 상태")
        처리하기()
    }
    "비활성" => 출력("비활성")
    _ => 출력("알 수 없음")
}

Pattern Types

PatternExampleDescription
Integer42Matches exact integer
String"hello"Matches exact string
Boolean, 거짓Matches boolean
Wildcard_Matches anything
BindingxMatches anything, binds to variable x
Array[1, 2, 3]Matches array structure

Variable Binding

맞춤 값 {
    0 => 출력("영")
    n => 출력(형식("값: {0}", n))
}