How do i interpret this

I found this construction :
type ->[A,B] = (A,B)
I looked up throught :

At least i found the answer, it’s just an type alias for tuple
type ->[A,B] = (A,B)

  • def something(seq: Int->String*)
  • def something(seq: ->[Int, String]*)
  • something((1,“1”))
  • something(1 -> “1”)
    As i realized definitions and calls above are equal.

Note that the -> pair factory method, defined for arbitrary types in Scala’s Predef, is unrelated to this type alias.

The -> type probably is intended for infix notation, i.e. instead of ->[Int, String] you’d write Int -> String. (Infix notation works for any type with two parameters, although it only shines with operator-like type names - you can write Int Either String, as well.)

1 Like

Thanks for pointing at ArrowAssoc.

Your link to the FAQ has a section, “Methods provided by implicit conversion”, which talks about ->.

Unfortunately, the link to an index in the Scaladoc is broken. It used to point here, where the entry for -> points to ArrowAssoc. The Scaladoc for that isn’t useful, but at least you know where the operator is introduced, so you could grep for it in the open source project.

I don’t know why it’s called open source instead of greppable source.