J.WeakRef

opaque type WeakRef[A]

Weakly Referenced Instance

J.WeakRef value will be garbage collected in case there is no other reference to it

Note. The returned get_? should be used for basic checks only. It should not be subjected to chain transformations, as this creates more references to the weak value

 var hr = new Object       // hard reference

 val wr = J.WeakRef(hr)    // weak reference

 wr.get_?.isEmpty.tp       // Prints: false

 hr = null                 // Clearing hard refference
 System.gc                 // Run garbage collection

 wr.get_?.isEmpty.tp       // Prints: true
Source
__.scala

Def

@scala.annotation.targetName("get_Opt")
def get_?[A]: Opt[A]

Value Option

Value Option

Returns value option

Source
__.scala

Given

Implicit

implicit inline def implicitToBoolean[A](inline v: J.WeakRef[A]): Boolean
Source
__.scala