flatMap忽略结果

问题描述 投票:1回答:1

我想知道是否存在在flatMap中忽略结果的函数(在scala或cat中)。例如:

Some("ignore this").ignoreArgumentFlatMap(Some("result"))

将与]相同>

Some("ignore this").flatMap(_ => Some("result"))

我想知道是否有一个函数(在scala或cat中),它忽略了flatMap中的结果。例如。 Some(“ ignore this”)。ignoreArgumentFlatMap(Some(“ result”))与Some(“ ...

scala monads scala-cats
1个回答
1
投票

在猫中被称为>>。>>

scala> Option("ignore this") >> Some("result")
res14: Option[String] = Some(result)
© www.soinside.com 2019 - 2024. All rights reserved.