In Scala (2.9.2) I am trying to create a function that provides some other value when accessed
() => Any
I thought I was successfully doing this via a by name / currying solution:
def byName(theValue : => Any)() : Any = theValue
val myHolder = byName(myValue)_
So my holder is of the correct type. However I find that in the course of creating this curried function the by name parameter is evaluated. If I do the following instead it works as intended:
def byName(theValue : => Any) : Any = () => theValue
val myHolder = byName(myValue)
I conclude some part of the currying process is referencing the first parameter list and triggering its evaluation. Can anybody confirm that and/or explain why or if there are any guidelines around using by name parameters with multiple parameter lists?