Scala : Path-dependent Types

There is no better way to understand path dependent types and their importance in Scala other than by directly looking at the problem that they help us solve.

Let us implement a very simple Lock/Key using Scala.

A simple lock and key

We defined a Lock and a Key class. You need a key to open a lock. Looks neat! Lets use it..