Skip to content

Instantly share code, notes, and snippets.

@LouisCAD
Last active June 8, 2018 07:19
Show Gist options
  • Select an option

  • Save LouisCAD/7ce3a30cb88c27858b12d5f26c118b0b to your computer and use it in GitHub Desktop.

Select an option

Save LouisCAD/7ce3a30cb88c27858b12d5f26c118b0b to your computer and use it in GitHub Desktop.
import java.lang.ref.WeakReference
import kotlin.reflect.KProperty
class WeakRef<out T>(value: T) {
private val ref = WeakReference<T>(value)
operator fun getValue(thisRef: Any?, property: KProperty<*>): T? = ref.get()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment