score:15
Accepted answer
the shortest is probably
(x ++ y).reduceleftoption(f)
which works because of an implicit conversion from option
to iterable
which happens to have a method that does exactly what you need.
Source: stackoverflow.com
Related Query
- Are Options and named default arguments like oil and water in a Scala API?
- what are the options for hadoop on scala
- Coalescing options in Scala
- Which is best data access options available for Play framework with Scala and PostgreSQL?
- guidance on jvm options in idiomatic scala
- Scala naming convention for options
- Idiomatic Scala for Nested Options
- Scala for comprehension with future and options
- IntelliJ overrides Scala additional compiler options when synced from Gradle
- How do I pull apart Case Classes filled with Options in Scala
- Scala and Java Options do if present if not do something else construct
- Reducing options in scala?
- Lazily coalesce Options in Scala
- Sum a list of options in Scala
- Dealing with Options in Scala Play Template
- Scala sorting Options
- Scala - Match Tuple of Options
- Chaining scala Try instances that contain Options
- How do I use Scala Hashmaps and Options together correctly?
- Working with options in Scala (best practices)
- scala two options defined, return first, else return second
- Idiomatic Scala for Options in place of if/else/else chain
- Can I use Scala options to avoid the following NoSuchElementException?
- Idiomatic way to use Options in Scala
- Handling two Options in Scala
- concise way to filter and map a scala sequence of tuples containing options
- How to run scala worksheet with options ?
- chain style + scala options
- Idiomatic scala for getting a single option out of two Options and throwing exception if two are available
- Dealing Options from a Map.get in Scala
More Query from same tag
- scala-library imported twice?
- Scala transform a list of maps into a map of lists
- Unit testing Scala using mockito
- Create a custom Transformer In Java spark ml
- Why do I have to redefine an already defined variable in a trait when extending in Scala
- Sort unbound Comparable in Scala
- Reassign ArrayList in a better Way
- Why does Scala implicit resolution fail for overloaded method with type parameter?
- Scala pattern matching in a concurrent program
- How to create a map column to count occurrences without udaf
- write logs with CloudWatch : getNextToken error
- Where can I download the library .jar-files for Akka 2.5.6?
- How to map the Duration type to Interval?
- Functional way of doing a loop of operations on an array
- Compiler errors on a play 2.3 /reactivemongo application
- Pass a vector from Matlab to Scala Class
- Using Play framework with Scala, how can I humanize a Json Validation message?
- Error while trying to import Array._ and import org.apache.spark.sql.functions._ in Spark Scala
- How can I exclude newlines in Scala RegexParsers matches?
- Scala Futures: How to guarantee a non-null result?
- First click on button has an odd behaviour
- Scala pattern matching on object type
- How do I execute a list of effects?
- Is there any way to use Inject directly from model or other class without controller?
- Read first element and next element from a file SCALA
- Mockito matchers, scala value class and NullPointerException
- Deduplicate: Different File Contents Found Error for SBT and Scala
- Treating an SQL ResultSet like a Scala Stream
- scala - Getting a read-only sublist view of a List
- Function calls with returned tuple without intermediate value