FAQ
What about just using find:

val list = List[Foo]()
val found: Option[Foo] = list find { each => ... }

Also stops looping after the first hit.

Am Montag, 15. Juni 2015 08:23:13 UTC+2 schrieb Maks Atygaev:
Hi!

I have the below code:

var f = false

collection foreach { item => {
if ( ... ) {
f = true
}

... ... ...
}}

if (f) {
... ...
}

Is it possible to make it more functional way? Should I refactor it?


--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
groupscala-user @
categoriesscala
postedJun 15, '15 at 6:23a
activeJun 15, '15 at 7:15a
posts3
users3
websitescala-lang.org
irc#scala

People

Translate

site design / logo © 2022 Grokbase