score:5
According do docs:
exec can also be passed an Expression function.
... which is alias for:
Session => Validation[T]
Also pay attention to this excerpt from the first link:
For those who wonder how the plumbing works and how you can return a Session instead of Validation[Session] in the above examples, that’s thanks to an implicit conversion.
Now, with that info you can see that in the first case you are passing to exec
something of type Session => Session
(for which there is no implicit conversion to Expression[Session]
exists in scope) and you get compile error.
In the second case you're using placeholder/partial application for:
justDoIt("hello world")(_)
... which is equivalent of:
x => justDoIt("hello world")(x)
... which can benefit from implicit conversion of the return value (from Session
to Validation[Session]
) and, as a result whole expression gets inferred to be conforming Expression[Session]
which is just what exec
requires.
UPDATE: here is the relevant implicit that does the conversion.
UPDATE 2: to make your original example work you can simply change the return type of justDoIt
like this (to benefit from implicit conversion):
def justDoIt(param: String): Session => Validation[Session] = s => s.set("some", param)
Source: stackoverflow.com
Related Query
- Gatling exec function returned by function
- Parsing a Json response returned to Gatling
- Gatling exec with session
- printing values returned from scala function
- Scala - map function - Only returned last element of a Map
- In specs2, conditionally executing subtests on result returned from function that may throw exceptions
- Gatling pass data from feeder to exec
- Create a scala function to define Gatling HTTP request chains
- How do I control order of execution of exec statements in Gatling scenario?
- Scala assigning multiple returned values from a function
- How to call returned function with implicits without assigning to val
- Function calls with returned tuple without intermediate value
- Get value from map returned from function with implicit in Scala
- Update variables using multiple values returned from a function in Scala
- scala - process string parsed from gatling EL expression in place with anonymous function
- How can I create my own exec function which has extended functionality?
- How can I exec shell scripts from within a Gatling simulation?
- What to do if nothing returned in a Scala function
- How to print list returned by a function
- Is casting a function [X, Y] X => Y to X => () safe as long as I ignore the returned value?
- Scala: how to use immutable values returned from function
- Gatling - passing data from feeder to method in exec
- Is it possible to print the returned value of a function of different class in case of Anonymous object of scala
- Passing session to function in Gatling Java
- Calling two functions within another function in Gatling is not working
- Gatling exec block and session variables
- How to indicate in a human readable way that a function is returned within a function in scala?
- Parameter list VS returned function
- Use a function to generate a Gatling feeder
- Akka stream of Future messages returned in function
More Query from same tag
- Can I change the linearization of types in Scala?
- Call different Java parent constructor from Scala with Android
- Spark: run an external process in parallel
- Create a json deserializer and use it
- filter the lines by two words Spark Streaming
- Restricting parameters to defined types in Scala
- Why does this error occur when compiling with SBT?
- Using operator (or synthetic function) as a parameter
- How to schedule a task at specific time in Scala?
- Scala 2.10: Array + JSON arrays to hashmap
- Scala Inheritance (Too Many Arguments For Constructor)
- How to sum all of the values in the input sequence in parallel?
- Defining the future implicit context in Play for Scala
- Implicit conversion of a function to a second-order-function only works if the function to convert has at least two parameters
- How to use Numeric[T] to represent zero of any numeric type
- How to merge two case class sequences based on an id in Scala?
- How do I break out of a play framework template loop?
- Why does this "aliasing" work in scala?
- SparkSQL sum if on multiple conditions
- Mockito Scala overloaded method value thenReturn with alternatives
- How to apply a simple filter with Flink in Scala
- Spark2.1.0 incompatible Jackson versions 2.7.6
- How to extract hostname and port from URL string?
- sbt dependsOn % "compile->compile;test->test"
- scala play! page only for new users
- How to make a thread run faster?
- Scala case classes in collections
- How to add current_timestamp() column to a streaming dataframe?
- Spark Graphx: Loading a graph from adjacency matrix
- Request is missing required `Host` header error in Scala Play 2.6.7 Akka