0
\$\begingroup\$

This Java answer (and this one) uses a lambda that does not explicitly declare its parameter type, but this Scala answer includes a parameter type. in both cases, the type could be inferred when it is assigned to a variable. For example, for a lambda that takes an int and returns an int:

Function<Integer, Integer> f = a->... // Java
val f: Int => Int = a=>... // Scala

My question is: should the type parameters be included in the lambda, or can we assume that they are declared as above?

\$\endgroup\$
3
  • \$\begingroup\$ Is there any problem with being able to handle more input types than mandated by the spec? \$\endgroup\$ Mar 21, 2017 at 15:29
  • \$\begingroup\$ @JanDvorak what do you mean? \$\endgroup\$ Mar 21, 2017 at 15:46
  • \$\begingroup\$ @Poke I think that answers it. \$\endgroup\$ Mar 21, 2017 at 15:50

0

Browse other questions tagged .