我有一个返回(String) => Try[(Long, String)]
类型的方法,我希望获得(Long, String)
。有什么建议吗?
我认为map / flatMap会有所帮助,但看起来却没有。
更新
def someMethod():(Long, String) = {
val result: (String) => Try[(Long, String)] = someOperation()
//Need to get (Long, String) from result
}
答案 0 :(得分:4)
有几个选项
Alias /newfolder/ "C:/www/newfolder/"
<Directory "C:/www/newfolder">
Options Indexes MultiViews
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
提供后备价值
val exceptional: Try[(Long, String)] = ???
val default: (Long, String) = (0, "")
处理异常,然后安全地exceptional.getOrElse(default)
get
或使用模式匹配
exceptional.recover { case exception => default }.get