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