Skip to content

Commit c16b4cb

Browse files
committed
Update '***OrElse' to use Option.getOrElse
1 parent 4d0e246 commit c16b4cb

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/observables/BlockingObservable.scala

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ class BlockingObservable[+T] private[scala] (val o: Observable[T])
9595
* @return the last item emitted by the source Observable, or a default item if the source Observable is empty
9696
*/
9797
def lastOrElse[U >: T](default: => U): U = {
98-
lastOption match {
99-
case Some(element) => element
100-
case None => default
101-
}
98+
lastOption getOrElse default
10299
}
103100

104101
/**
@@ -149,10 +146,7 @@ class BlockingObservable[+T] private[scala] (val o: Observable[T])
149146
* @return the very first item from the source, or a default value if the source Observable completes without emitting any item.
150147
*/
151148
def headOrElse[U >: T](default: => U): U = {
152-
headOption match {
153-
case Some(element) => element
154-
case None => default
155-
}
149+
headOption getOrElse default
156150
}
157151

158152
/**
@@ -222,10 +216,7 @@ class BlockingObservable[+T] private[scala] (val o: Observable[T])
222216
* @throws IllegalArgumentException if the source Observable emits more than one item
223217
*/
224218
def singleOrElse[U >: T](default: => U): U = {
225-
singleOption match {
226-
case Some(element) => element
227-
case None => default
228-
}
219+
singleOption getOrElse default
229220
}
230221

231222
/**

0 commit comments

Comments
 (0)