home search about rss feed twitter ko-fi

Mathematical Expressions (Scala 3 Video)

Scala’s mathematical “operators” are the same as other languages:

  • +
  • -
  • *
  • /
  • %

Because Scala is an OOP language, these aren’t really operators, they’re methods on the numeric data types.

When you use a var, you can also use these:

  • +=
  • -=
  • *=
  • /=
  • %

Example:

var a = 1
a += 10
a -= 1

Update: All of my new videos are now on
LearnScala.dev