scala - How to convert Iterable[Try[U]] filter successed to Iterable[U]? -


i tried

val tryvalues : iterable[try[int]] = ... val successvalues = tryvalues.filter(_.issuccess).map(_.get) 

but compiler give warning map may throw exception. there way free of warning?

another option here, if don't care log fails flatmap using tooption on try. so:

val successvalues = tryvalues.flatmap(_.tooption) 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -