diff options
author | Janek Bogucki <janekdb@gmail.com> | 2015-08-04 08:45:58 +0100 |
---|---|---|
committer | Janek Bogucki <janekdb@gmail.com> | 2015-08-04 08:45:58 +0100 |
commit | 58ae3e51f7d0ac0f4a56deaab5f90ab5048350fe (patch) | |
tree | a714df8b46e44f8537bc6f1b5ac11e056ebad488 /src/library/scala/ref | |
parent | a745f06e35e070061348e95725afb0def8ca45de (diff) | |
download | scala-58ae3e51f7d0ac0f4a56deaab5f90ab5048350fe.tar.gz scala-58ae3e51f7d0ac0f4a56deaab5f90ab5048350fe.tar.bz2 scala-58ae3e51f7d0ac0f4a56deaab5f90ab5048350fe.zip |
Delegate null test to Option
Option(null) is None while Option(v) is Some(v) which makes the null
test redundant.
Diffstat (limited to 'src/library/scala/ref')
-rw-r--r-- | src/library/scala/ref/WeakReference.scala | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/library/scala/ref/WeakReference.scala b/src/library/scala/ref/WeakReference.scala index 6ee40aed5c..9dcc0bbe5f 100644 --- a/src/library/scala/ref/WeakReference.scala +++ b/src/library/scala/ref/WeakReference.scala @@ -28,10 +28,7 @@ object WeakReference { def apply[T <: AnyRef](value: T) = new WeakReference(value) /** Optionally returns the referenced value, or `None` if that value no longer exists */ - def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = { - val x = wr.underlying.get - if (x != null) Some(x) else None - } + def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = Option(wr.underlying.get) } /** |