Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Multiple types inside a type bracket means type parametrization on multiple types. Take for example</p> <pre><code>trait Pair[A, B] </code></pre> <p>This is a pair of values one having type <code>A</code> the other having type <code>B</code>.</p> <p><strong>Update:</strong></p> <p>I think you are interpreting too much into the semantics of type parameters. A type parametrized by multiple parameters is just that and nothing more. The position of a specific type parameter in the list of type parameters does not make it special in any way. Specifically the last parameter in a list of type parameters does not need to stand for 'the return type'. </p> <p>The sentence from the play framework which you quoted explains the semantics of the type parameters for this one specific type. It does not generalize to other types. The same holds for the <code>Function</code> types: here the last type parameter happens to mean 'the return type'. This is not necessarily the case for other types though. The type <code>Pair[A, B]</code> from above is such an example. Here <code>B</code> is the type of the second component of the pair. There is no notion of a 'return type' here at all.</p> <p>Type parameters of a parametrized type can appear anywhere inside the definition of the parametrized type where a 'regular' type could appear. That is, type parameters are just names for types which are bound to the actual types only when the parametrized type itself is instantiated. </p> <p>Consider the following definition of a class Tuple:</p> <pre><code>class Tuple[A, B](a: A, b: B) </code></pre> <p>It is instantiated to a type of a tuple of Int and String like this:</p> <pre><code>type TupleIntString = Tuple[Int, String] </code></pre> <p>Which is essentially the same as </p> <pre><code>class TupleIntString(a: Int, b: String) </code></pre> <p>For an official source check the <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf" rel="nofollow">Scala Language Specification</a>. Specifically Section 3.4 "Base Types and Member Definitions" under 1. the 4th bullet point says: "The base types of a parameterized type C[T_1, ..., T_n] are the base types of type C , where every occurrence of a type parameter a_i of C has been replaced by the corresponding parameter type T_i." </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload