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
ByNameTypeis 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
IntByNameis an abstract type with underlying=> Inttype.Given a by-name parameter of the return value of
getInt(),when
getIntreturns 42,getInt.when.once returns 42then the value of the the by-name parameter should be 42;
boxedByName.extract should be(42)when
getIntreturns 144,getInt.when.once returns 144then the value of the the by-name parameter should be 144.
boxedByName.extract should be(144)