Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And a another way to use tupled is:

    list map Function.tupled(plus)
Hereby additionally proving the old saying 'if you need help with a product don't say you need help because you'll get hit with RTFM, just say too bad you can't do X in product while it's easy to do in [competing product], and everyone will try to prove you wrong.'


> and everyone will try to prove you wrong

heh, how true, though more of an invitation; a strength/weakness of Scala is the fact that there's often more than one way to do the same thing (at least 3 ways have been shown with the current example). From what I've seen F# does not have this characteristic.

Anyway, ideally the Scala compiler would provide the same level of concision that for comprehensions do vis-a-vis flatMap/map boilerplate, thus reducing our example down to: `list map plus`, the bare essentials ;-)

Worth noting that the source for Function[0] indicates `Function.tupled` methods are slated for removal in future: "these functions are slotted for deprecation, but it is on hold pending superior type inference for tupling anonymous functions"

https://github.com/scala/scala/blob/v2.11.4/src/library/scal...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: