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.
In [46]:
// Create an integer variable of 10
var i:Int = 10
In [47]:
// Increment up 1
i += 1
// View variable
i
Out[47]:
In [48]:
// Decrement up 1
i -= 1
// View variable
i
Out[48]:
In [49]:
// Increment up x2
i *= 2
// View variable
i
Out[49]:
In [50]:
// Decrement down by half
i /= 2
// View variable
i
Out[50]: