2

Types within Scala are referred to via two mechanisms: One is called 'path-dependent type'(.),and other is 'type projection'(#).

What is the difference between two?

Mandroid
  • 6,200
  • 12
  • 64
  • 134
  • This answer explains it really well: https://stackoverflow.com/questions/9443004/what-does-the-operator-mean-in-scala – curious Mar 29 '18 at 15:20

1 Answers1

0

Let me try to demonstrate it with examples.

scala> class A {
     |   type B = Int
     | }
defined class A

scala> implicitly[Int =:= A#B]
res1: Int =:= Int = <function1>

scala> val a = new A
a: A = A@20864cd1

scala> implicitly[Int =:= a.B]
res2: Int =:= a.B = <function1>


scala> implicitly[Int =:= a#B]
<console>:12: error: not found: type a
       implicitly[Int =:= a#B]
                          ^

scala> implicitly[Int =:= A.B]
<console>:12: error: not found: value A
       implicitly[Int =:= A.B]
                          ^
mpetruska
  • 633
  • 3
  • 6