->
is actually just an operator to make creating a Tuple2 (or Pair) object easier. See the hairy details, for "how" such an operator can work across different types.
The normal/predef meaning of the ->
operator is such that x -> y
is equivalent to Tuple2(x, y)
, where y
is just an expression. The code can then use any expression (reserved words or not) that is valid in the context.
In Play, note that nonEmptyText
is itself just a value and does not involve any reserved words. Likewise, tuple
is just a method for Play; see Handling form submission.