Inherited from Serializable
Inherited by implicit conversion any2stringadd from
ByName[ByNameType] to any2stringadd[ByName[ByNameType]]
Inherited by implicit conversion StringFormat from
ByName[ByNameType] to StringFormat[ByName[ByNameType]]
Inherited by implicit conversion Ensuring from
ByName[ByNameType] to Ensuring[ByName[ByNameType]]
Inherited by implicit conversion ArrowAssoc from
ByName[ByNameType] to ArrowAssoc[ByName[ByNameType]]
A type class for convert between by-name type and normal by-value type.
This ByName type class provide an extension method extract for ByName.=> types via implicit view, which can be import as follow:
import com.thoughtworks.feature.ByName.ops._
Author:
杨博 (Yang Bo) <[email protected]>
The by-name type
When using this ByName type class, you should make sure the type parameter
ByNameType
is an abstract type, in case of Scala compiler bugs. You can use a trick similar to C++'s Pimpl Idiom to create opacity abstract typesNow
IntByName
is an abstract type with underlying=> Int
type.Given a by-name parameter of the return value of
getInt()
,when
getInt
returns 42,getInt.when.once returns 42
then the value of the the by-name parameter should be 42;
boxedByName.extract should be(42)
when
getInt
returns 144,getInt.when.once returns 144
then the value of the the by-name parameter should be 144.
boxedByName.extract should be(144)