4

This is surely a stupid question, but I'm stumped. I've now read Odersky's book, and all the tutorials I can get my hands on, and I can't seem to find anything which explains some of the more obscure Scala type relationships. For example, what is =:=? It's referenced here, but doesn't even seem to be in the Scala language reference. Is there some reference material which explains this, which I'm missing?

Tim
  • 766
  • 1
  • 7
  • 13
  • 3
    Specifically for `=:=` and related operators, see http://stackoverflow.com/questions/3427345/what-do-and-mean-in-scala-2-8-and-where-are-they-documented. – Alexey Romanov Oct 16 '11 at 05:52
  • bookmark [1st ed Staircase book](http://www.artima.com/pins1ed/) from artima.com, the index is great for symbolic "operators" which are really (mostly) methods/functions: – Gene T Oct 19 '11 at 20:45
  • Alexey: Ah! Thank you! Very helpful... and Wow! that's weird! – Tim Oct 20 '11 at 04:16

2 Answers2

3

It's just a "normal" operator, albeit one that is somewhat obscure (and one that I have never used or heard about before ;-). The =:= operator is defined in the [magical] Predef object.

See section 12.5: The Predef Object in the SLS:

The Predef object defines standard functions and type aliases for Scala programs. It [Predef] is always implicitly imported, so that all its defined members are available without qualification.

(The SLS does not mention =:= or a few others; many are "implementation details".)

Happy coding.

  • 1
    Pedantry: `=:=` is not an operator; it's a class – Luigi Plinge Oct 16 '11 at 21:01
  • @Luigi Plinge I tried to work out *how* it was applied, but failed miserably. A step by step "guide" of how such stuff in Predef even works would be nice! (Know of any? :-) –  Oct 17 '11 at 00:45
0

The Scaladoc says:

An instance of A =:= B witnesses that the types A and B are equal.

I did not have any trouble finding it, nor do I have any trouble understanding it (though knowing beforehand biases me in this). To improve it, I'd like to know what do you have a problem with: finding it, understanding it, or both?

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
  • I didn't realize it might be in the Scala API -- nor that it was a *class*! I'd assumed it was a built-in type relationship of some sort, and thus was expecting in the language definition itself. (It also doesn't help that Google can't easily search on such strings.) – Tim Oct 20 '11 at 04:12