scala-option
Where is the method that boxes an AnyRef into an Option?
In this blogpost by James Iry, he writes: Plus, Scala has an \"option\" method that promotes a value to either Some(value) or None depending on whether it\'s null or not ...[详细]
2023-02-08 18:33 分类:问答Wrapping null-returning method in Java with Option in Scala?
开发者_高级运维Suppose I have a method session.get(str: String): String but you don\'t know whether it will return you a string or a null, because it comes from Java.[详细]
2023-02-05 04:39 分类:问答Composing Option with List in for-comprehension gives type mismatch depending on order
Why does this construction cause a Type Mismatch error in Scala? for (first <- Some(1); second <- List(1,2,3)) yield (first,second)[详细]
2023-02-05 00:47 分类:问答Option monad in scala
how is meant to work Option monad? I\'m browsing the scala api and there is an example (I mean the second one),[详细]
2023-01-27 16:27 分类:问答How can I reverse of flow of Option Monad?
say, I have a bunch of \"validation\" functions that return None if there is no error, otherwise it returnSome(String) specifying the error message.Something like the following ...[详细]
2023-01-24 22:45 分类:问答scala return on first Some in list
I have a list l:List[T1] and currently im doing the following: myfun : T1 -> Option[T2] val x: Option[T2] = l.map{ myfun(l) }.flatten.find(_=>true)[详细]
2023-01-15 01:16 分类:问答Are Maybes a good pattern for scala?
For a while I have been struggling to integrate scala with java methods that might return null.I came up with the following utility w开发者_开发问答hich helps a lot:[详细]
2023-01-01 23:21 分类:问答Why does Option not extend the Iterable trait directly?
Option is implicitly convertible to an Iterable - but why does it not just just implement Iterable directly:[详细]
2022-12-26 11:00 分类:问答Convert a List of Options to an Option of List using Scalaz
I want to transform a List[Option[T]] into a Option[List[T]]. The signature type of the function is def lo2ol[T](lo: List[Option[T]]): Option[List[T]][详细]
2022-12-25 06:13 分类:问答Using Option all over the place feels a bit awkward. Am I doing something wrong?
As a result of articles I开发者_如何学Python read about the Option class which helps you avoid NullPointerException\'s, I started to use it all over the place. Imagine something like this:[详细]
2022-12-23 17:11 分类:问答