https://kotlinlang.org logo
g

groostav

08/05/2016, 2:23 AM
@rocketraman: I was just thinking along these lines in properties, I dont want to use reflection, what I'd really like is the ability to quickly and easily wrap a property up as a field --what I'm going to call the
by
operator's dual.
Copy code
class Delegate<THost, TProp>{

  var value: TProp? = null
  fun getValue(): TProp { return value; }
  fun setValue(value: TProp) { this.value = value }
}
class SomeClass(){
  val prop: Int by delegate { things(); }
}
I want to then write
Copy code
val instance = SomeClass();

val delegate: Delegate<SomeClass, Int> = yb { instance.prop }
--though I think
yb
would be a terrible name for this operator.