What will be the result of calling method forall on empty Option?
val a = None

a.forall(_ == "text") 
Explanation
forall is defined in a following way:
final def forall(p: (A) => Boolean): Boolean
Returns true if this Option is empty or the predicate p returns true when applied to this Option's value.

You could rephrase that forall means that none of the elements of the Option violate the given predicate. In case there are no elements, none of them violates it.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Scala
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты