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
Зареєструйся Зараз
або Підпишись на майбутні тести