Un-optioning an optioned Option

后端 未结 6 1137
甜味超标
甜味超标 2021-02-02 07:05

Say I have a val s: Option[Option[String]]. It can thus have the following values:

Some(Some(\"foo\")) Some(None) None

6条回答
  •  后悔当初
    2021-02-02 07:30

    s.flatten
    

    followed by a bunch of characters to get me up to the minimum that stackoverflow allows

提交回复
热议问题