The parameter value here is never used and is therefore redundant. The method sample() returns a function which takes one integer parameter (which is discarded) and then adds 1 to it. So you get:
scala> def sample(value:Int) = { (x:Int) => x + 1 } sample: (value: Int)Int => Int scala> sample(100) res2: Int => Int = <function1> scala> sample(100)(10) res3: Int = 11 scala> val f = sample(99) f: Int => Int = <function1> scala> f(1) res4: Int = 2
You could use the value parameter in the following way:
scala> def plusX(value:Int) = { (x:Int) => x + value} plusX: (value: Int)Int => Int scala> val plus10 = plusX(10) plus10: Int => Int = <function1> scala> plus10(15) res7: Int = 25
Now plusX creates a function which takes a integer and adds the value value to it
sampleis a function which returns an anonymous function. All the concepts you're playing around, you just need to read them up a bit: docs.scala-lang.org/tutorials/tour/… and docs.scala-lang.org/tutorials/tour/higher-order-functions