Title: If Else
Slug: if_else
Summary: If Else Using Scala.
Date: 2017-01-03 12:00
Category: Scala
Tags: Basics
Authors: Chris Albon

If you want a deeper guide to Scala, when I was learning I used Programming Scala and Scala for Data Science.

Create A Value


In [12]:
// Create a value called x that is a short integer of 3
val x: Short = 3

Create A Conditional Expression


In [26]:
// Create a value that is 1 if x is greater than 0, otherwise -1
val binary = if (x > 0) 1 else -1

// View that value
binary


Out[26]:
1