KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What is the difference between the types of the following two functions? def add1: Int => Int => Int = a => b => a + b def add2(a: Int)(b: Int) = a + b Based on their declarations, they seem to have the same type. Both are called in the same way: scala> add1(1)(2) res2: Int = 3 scala> add2(1)(2) res3: Int = 3 However, there is an apparent difference in their types: scala> :t add1 Int => Int => Int scala> :t add2 (a: Int)(b: Int)Int Additionally, partial application of add1 is a bit cleaner than of add2 . scala> add1(1) res4: Int => Int = <function1> scala> add2(1)(_) res5: Int => Int = <function1>
Tags (comma-separated)
Save Edits
Cancel