JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
Kotlin
Kotlin Documenation
More
Share
Explore
Kotlin Documenation
Conditional expressions
If-else
var
max
=
a
if
(
a
<
b
)
max
=
b
// With else
if
(
a
>
b
)
{
max
=
a
}
else
{
max
=
b
}
// As expression
max
=
if
(
a
>
b
)
a
else
b
// You can also use `else if` in expressions:
val
maxLimit
=
1
val
maxOrLimit
=
if
(
maxLimit
>
a
)
maxLimit
else
if
(
a
>
b
)
a
else
b
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.