Ternary operator
Control flow / Conditional statements / if/else statements
Alternative form
Standard form
Common mistake
Complex conditions
Ternary operator
n =
-42
classify =
"positive"
if
n >
0
else
"negative"
# classify
is
'negative'
print
(f
"
{classify = }
"
)
Languages
C
C++
Java
C#
JavaScript
R
Rust
Golang
Delphi
PHP
Ruby
Swift
Kotlin
Lua
TypeScript
Clojure
Bash
Objective-C