3 ms·
Partial application of functions is fine. Partial functions would be disallowed. Here's a function that is only partial, because it can throw an exception inst
by philipkglass 8y ago
Partial application of functions is fine. Partial functions would be disallowed.
Here's a function that is only partial, because it can throw an exception instead of returning a value when b is zero:
def divide(a: Int, b: Int): Int = a / b
Here's a total function to accomplish the same basic goal:
def divide(a: Int, b: Int): Try[Int] = Try(a / b)
This function always returns a value of the type it's declared to return.
- tunesmith 8y agoThanks for that clarification. I had googled for "partial function vs currying", which led me to results for "partial function application", which was really about partial application of functions, not partial functions. :-/ I swear, probably 80% of my problems in professional life are from overloaded terms.
- AnimalMuppet 8y agoBy "overloaded", do you mean "having multiple definitions"? Or do you mean "carrying too much weight"? ;-)
- dllthomas 8y ago> Partial functions would be disallowed. Some partial functions would be disallowed, assuming you aren't including an actual totality check (which would exclude all partial functions and some total ones).