Given the following function,
def sum(a: Int, b: Int) = a + b
Select all correct ways to store function in a variable.
Explanation
Get an explanation when it's available:
Theory
  • A partially applied function is an expression in which you don't supply all of the arguments needed by the function. Instead, you supply some, or none, of the needed arguments. For example, to create a partially applied function expression involving sum,
    scala> def sum(a: Int, b: Int, c: Int) = a + b + c
    sum: (a: Int,b: Int,c: Int)Int
    
    in which you supply none of the three required arguments, you just place an underscore after "sum". The resulting function can then be stored in a variable. Here's an example:
    scala> val a = sum _
    a: (Int, Int, Int) => Int = 
    
    Read more: Partially applied functions

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Scala
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести