Avatar ·

How to use ternary operator in Kotlin? (analog of ?: from Java)

Hello everyone! I just started learning Kotlin and am switching from Java. In Java, I often used the ternary operator for short conditions, for example: ```java int max = (a > b) ? a : b; ``` But in Kotlin I can't find such syntax. When I write: ```kotlin val max = (a > b) ? a : b ``` The compiler gives an error. I read that Kotlin doesn't have a ternary operator, but how do you write short conditional expressions then? Do I really have to write a full if-else every time? I need to solve a simple problem: there is a variable `score`, and depending on whether it's greater than 50, I want to assign the string "Pass" or "Fail". In Java I would write: ```java String result = (score > 50) ? "Pass" : "Fail"; ``` How can I do this concisely and correctly in Kotlin? Thanks in advance for your help!