W3cubDocs

/Kotlin

WeakReference

Platform and version requirements: Native (1.3)
class WeakReference<T : Any>

Class WeakReference encapsulates weak reference to an object, which could be used to either retrieve a strong reference to an object, or return null, if object was already destroyed by the memory manager.

Constructors

Platform and version requirements: Native (1.3)

<init>

Creates a weak reference object pointing to an object. Weak reference doesn't prevent removing object, and is nullified once object is collected.

WeakReference(referred: T)

Properties

Platform and version requirements: Native (1.3)

value

Returns either reference to an object or null, if it was collected.

val value: T?

Functions

Platform and version requirements: Native (1.3)

clear

Clears reference to an object.

fun clear()
Platform and version requirements: Native (1.3)

get

Returns either reference to an object or null, if it was collected.

fun get(): T?

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.ref/-weak-reference/index.html