v Increment And Decrement Numbers - Scala

Increment And Decrement Numbers

This tutorial was inspired by the awesome Scala Cookbook.

Create Integer Variable

// Create an integer variable of 10
var i:Int = 10

Increment And Decrement

// Increment up 1
i += 1

// View variable
i
11
// Decrement up 1
i -= 1

// View variable
i
10
// Increment up x2
i *= 2

// View variable
i
20
// Decrement down by half
i /= 2

// View variable
i
10