Ternary operator in Kotlin, Swift, Python Development 01.10.2019

The ternary conditional operator takes a condition and returns one of two values, depending on whether the condition was true or false.

Kotlin

val a = 5
val b = 10
val min = if (a < b) a else b

Swift

let a = 5
let b = 10
let min = a < b ? a : b

Python

a = 5
b = 10
min = a if a < b else b