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

java - Ebean enhancement ignores a model -

ubuntu - How to disable Kernel Module Signing in linux -

SQL php on different pages to Insert (mysqli) -