Title: Increment And Decrement Numbers
Slug: increment_and_decrement_numbers
Summary: Increment And Decrement Numbers Using Scala.
Date: 2017-01-03 12:00
Category: Scala
Tags: Basics
Authors: Chris Albon

This tutorial was inspired by the awesome Scala Cookbook.

Create Integer Variable


In [46]:
// Create an integer variable of 10
var i:Int = 10

Increment And Decrement


In [47]:
// Increment up 1
i += 1

// View variable
i


Out[47]:
11

In [48]:
// Decrement up 1
i -= 1

// View variable
i


Out[48]:
10

In [49]:
// Increment up x2
i *= 2

// View variable
i


Out[49]:
20

In [50]:
// Decrement down by half
i /= 2

// View variable
i


Out[50]:
10