
上QQ阅读APP看书,第一时间看更新
Assigning result to an expression using the if keyword
In Kotlin if is special because it returns values. That is why we can use an if statement to assign values to a result. This removes the need for a ternary operator in Kotlin. Let's see how we can use if statements to assign value.