orangy
06/22/2018, 8:56 PMHullaballoonatic
06/23/2018, 4:22 PMgcx11
06/23/2018, 5:10 PMHullaballoonatic
06/23/2018, 5:11 PMscalingProperty
and i want to be able to implement this interface but allowing to name the property as something with context, like volume
var volume: Volume
get() = scalingProperty
set(v) {
scalingProperty = v
}
orangy
06/23/2018, 6:00 PMvar YourInterface.volume : Volume
and the rest is as you wroteinstance.volume
, right?Hullaballoonatic
06/23/2018, 6:00 PMinterface Liquid<T: ItemData> : Scale<Volume, T> {
override var scalingProperty: Volume
get() = volume
set(value) {
volume = value
}
var volume: Volume
}
orangy
06/23/2018, 6:13 PMscalingProperty
final, so that it wouldn’t be overriden further in hierarchyHullaballoonatic
06/23/2018, 6:14 PMorangy
06/23/2018, 6:15 PMVolume
should have property `volume`:
interface Scale<TUnit, TData> {
var scalingProperty: TUnit
}
interface Volume
object Barrel : Volume
var <TData> Scale<Volume, TData>.volume
get() = scalingProperty
set(value) {
scalingProperty = value
}
fun test(some: Scale<String, Int>, liquid: Scale<Volume, Int>) {
some.volume = Barrel // error
liquid.volume = Barrel // ok
}
Hullaballoonatic
06/23/2018, 6:25 PMorangy
06/23/2018, 6:29 PMobject : Volume {}
?Hullaballoonatic
06/23/2018, 6:30 PMorangy
06/23/2018, 6:32 PM