0
\$\begingroup\$

This question already has an answer here:

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\$

marked as duplicate by Poke, Mego, Nathan Merrill, Matthew Roh, mbomb007 Mar 21 '17 at 16:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

Browse other questions tagged .