The element type of the returned collection. lettersOf will return a Set, not a Seq def lettersOf(words: Seq) = words.toSet flatMap ((word: String) => word.toSeq) ![]() For example: // lettersOf will return a Seq of likely repeated letters, instead of a Set def lettersOf(words: Seq) = words flatMap (word => word.toSet) This mightĬause unexpected results sometimes. The type of the resulting collection is guided by the static type of immutable queue. Definition Classes PartialFunctionĬast the receiver object to be of type T0.īuilds a new immutable queue by applying a function to all elements of this immutable queueĪnd using the elements of the resulting collections.įor example: def getWords(lines: Seq): Seq = lines flatMap (line => line split "\\W+") The result of this function or fallback function application. This may result in better performanceĪnd more predictable behavior w.r.t. It is recommended to override applyOrElse with custom implementation that avoidsĭouble isDefinedAt evaluation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |