r/functionalprogramming • • Feb 11 '20

Java What Java has learned from functional languages

https://youtu.be/e6n-Ci8V2CM?list=PLEx5khR4g7PLHBVGOjNbevChU9DOL3Axj
22 Upvotes

13 comments sorted by

View all comments

Show parent comment

4

u/blamedrop Feb 12 '20

And some of you might enjoy this version even more :D

val capacity: Vehicle => Int = {
  case Car("red") => 20
  case Car(_) => 4
  case Bus => 12
}