default

    [Swift 제어문] switch case 사용해 다중 조건 처리하기

    [Swift 제어문] switch case 사용해 다중 조건 처리하기

    switch case문 이란? switch case 문은 많은 분기를 처리하기 위해 만들어진 문법이다. switch 문의 필요성 if else 문으로 다양한 조건을 처리하려면 else if 를 무한 반복해야 하는데 이는 가독성을 매우 떨어트린다. if value == "A" { print("value is A") } else if value == "B" { print("value is B") } else if value == "C" { print("value is C") } ... 프로그래밍은 가독성이 매우 중요하므로, 분기가 4개 이상인 상황에서는 다음과 같이 switch case 문을 사용해 분기를 처리하는 것이 좋다. let value = "Hello Swift" switch(value){ case..