score:2
Accepted answer
writing simply sum _
does not yet have anything to do with the arguments of sum
, but simply distinguishes the function object sum
from an application of the function.
hence, you can write:
scala> val partfunc2 = sum _
partfunc2: int => (int => int) = <function1>
as you can see from the type information, this is already the curried version of sum
which takes two int
parameters.
of course, you can then proceed as before with partfunc2(4)
being of type int => int
and so on.
score:1
you can do it like this:
val partfunc2 = sum _
or like this:
val partfunc2 = sum(3) _
Source: stackoverflow.com
Related Query
- Scala - mutable (var) method parameter reference
- How to pass a class method as a parameter in Scala
- Scala 2.12.2 emits a ton of useless "Warning: parameter value ... in method ... is never used" warnings. How to get rid of them?
- Why does Scala evaluate the argument for a call-by-name parameter if the method is infix and right-associative?
- Why does currying in Scala need multiple parameter lists?
- Method call with option value or default parameter in Scala
- How do I encode this method with an implicit parameter group which contains a dependent type?
- Scala, Currying on multi parameter-group method including implicit params?
- scala currying by nested functions or by multiple parameter lists
- Scala method where type of second parameter equals part of generic type from first parameter
- Scala override method with subclass as parameter type
- How to call java method taking parameter as List<Class<?>> from Scala
- Getting method parameter types using scala 2.10 reflection API
- Is it possible to get the parameter names of a method in scala
- Scala implicit parameter null when implicit val defined after method call
- Scala compiler error due to constructor parameter (property) having same name in both base and derived class and used in derived method
- Scala invariant generic type parameter ignored by method parameter type depending whether argument is literal expression versus variable
- Preserve method parameter names in scala macro
- Mockito verify fails with "TooManyActualInvocations" for method with a default parameter in Scala
- Why does wrapping a method in another method stop type mismatch in Scala - using underscore in type parameter in pattern match?
- scala implicit class method type mismatch in reduce vs non-implicit method with function currying
- Supplying "Class" type as a parameter to a method in Scala
- scala - implementing trait method with parameter that is child of expected type
- Error passing generic values to method using implicit parameter in Scala
- Patterns for same method & same parameters but different parameter names in scala
- Scala : Generic method implicit parameter
- Scala - calling a method with generic type parameter given a string value that determines the correct type
- Scala Class Variable Name Hides Method Parameter Name
- Is it possible to call a scala method passed as a parameter in a Java method?
- Use method return value as default constructor parameter in Scala
More Query from same tag
- Akka priority mailbox and stash/unstash
- Intellij icon with two red horizontal lines
- How can I access args from trait?
- How can a class and companion object see private vals in Scala?
- Scala by Example - type bounds parametrized function compiler complains
- Execute external command
- Caused by: java.io.NotSerializableException: org.apache.spark.SparkContext - when using JdbcRDD in Spark
- How to resolve this exception Could not access term breeze in package <root>
- How to convert a list of items to lists of fixed size in scala
- How to check if any element of list starts with any character from given range?
- scala: What is the performance of creating a function in the function body
- Need some explanation to understand the map function in scala
- Swapping statements in for-comprehension in Scala shows strange behavior
- It is possible to run recent version of ScalaPB (0.6.x) with protobuf 2.5.0?
- How to specify OVERWRITE to writeAsText in Apache Flink Streaming 0.10.0?
- Basic repetition in scala
- How to reference a val in a case statement?
- Convert json array to scala list
- Akka (2.3.0) fails to load Slf4jEventHandler class with java.lang.ClassNotFoundException
- PlayFramework 2.x - Forms / Associating error message to one element of a tuple
- In Scala, why could remainder (%) operator return a negative number?
- Scala: Refactoring a case-statement to use for-comprehension
- Customise Freedesktop file with sbt-native-packager and JDKPackager plugin
- Using RemoteActors without future/ask
- How to write a Muller C Element in Chisel Scala Language for async circuit?
- Generic Method Implementing Two Traits
- Why does passing some functions in scala require _
- Verifying mocked object method calls with default arguments
- Naming scheme for helper functions in Scala
- Why Spark SQL translates String "null" to Object null for Float/Double types?