Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • control
  • if
  • ternary

Scala - Inline conditional

Execute one or other code block depending on condition in a single line. This ternary conditional code is shorter than explicit if statements.

0
483
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Using if else

if ({{condition}}) {{true_code}} else {{false_code}}
java

Notes

last update: Dec. 4, 2014

Advertisement

This project is hosted on DigitalOcean, try it and support us

Related concept

  • Break out of loop

Other language

  • C++
  • Python
  • JavaScript
  • C
  • PHP

Random task

  • Check if specific commit is on remote
  • String concatenation
  • Convert String to int
  • Transform rotate
  • Create key value container
  • Blog
  • About
  • License