
[Kotlin] 조건문과 반복문
·
Language/Kotlin
Kotlin if문`if 문`은 모든 언어에서 사용이되는 것처럼 조건을 판단하여 코드의 흐름을 제어한다.여러 조건을 사용해야 할 경우 자바와 동일하게 `else if`, `else` 키워드를 사용하면 된다. if 문의 문법 예 var max = aif(a b){ max = a} else { max = b}// As expressionmax = if(a > b) a else b// You can also use 'else if' in expressions:val maxLimit = 1val maxOrLimit = if (maxLimit > a) maxLimit else if (a > b) a else b when 문when문은 여러 케이스에 대해 구분하기 위해 사용되며, if문을 사용하기엔 비교적 케이..