@@ -248,18 +248,22 @@ differ from a function value such as:
248
248
249
249
val square: Int => Int = x => x * x
250
250
251
- For Scala 2, there is a [ complete answer on Stack Overflow] ( https://stackoverflow.com/a/2530007/4111404 )
251
+ For ** Scala 2** , there is a [ complete answer on Stack Overflow] ( https://stackoverflow.com/a/2530007/4111404 )
252
252
and a [ summary with practical differences] ( https://tpolecat.github.io/2014/06/09/methods-functions.html ) .
253
253
254
- Note that in ** Scala 3** the differences are fewer;
255
- for example, they will be able to
256
- [ accept implicit parameters] ({{ site.scala3ref }}/contextual/context-functions.html)
257
- as well as [ type parameters] ({{ site.scala3ref }}/new-types/polymorphic-function-types.html).
258
-
259
- Nevertheless, it is still recommended to use methods most of the time,
260
- unless you absolutely need a function. And, thanks to
261
- [ eta-expansion] ( https://stackoverflow.com/questions/39445018/what-is-the-eta-expansion-in-scala )
262
- you rarely would need to define a function rather than a method.
254
+ In ** Scala 3** , the differences are fewer.
255
+ [ Context functions] ({{ site.scala3ref }}/contextual/context-functions.html)
256
+ accept given parameters and
257
+ [ polymorphic functions] ({{ site.scala3ref }}/new-types/polymorphic-function-types.html)
258
+ have type parameters.
259
+
260
+ It's standard to use methods most of the time,
261
+ except when function value is actually needed.
262
+ [ Eta-expansion] ( https://stackoverflow.com/questions/39445018/what-is-the-eta-expansion-in-scala ) ,
263
+ converts methods to functions when needed.
264
+ For example, a method such as ` map ` expects a function,
265
+ but even if you ` def square ` as shown above, you can
266
+ still ` xs.map(square) ` .
263
267
264
268
### What's the difference between types and classes?
265
269
0 commit comments