louiscad
11/02/2018, 6:09 PMclass SomeClass : CharSequence by { privateWrapper.text }
, but I know it would clash with functional types…
then I thought about this:
If I had to choose between interface implementation by delegation to an expression, and function type implementation by delegation, what would I pick?
Of course I'd pick former! Why? Because it allows to implement multiple methods at once, while the latter only implements one method with an expression: meh. I can do it with override, it's not really longer.
So, what about deprecating implementation of function interfaces by delegation with the current syntax, to allow supporting the following code in the future?
class CharSequenceWrapper(val text: CharSequence)
class SomeClass : CharSequence by { privateWrapper.text } { // The expression is evaluated each time
private val privateWrapper = CharSequenceWrapper("Hello!")
}