一 try 表达式


Scala的try表达式和match表达式
 
二 match表达式

Scala的try表达式和match表达式
 
三 实例
  1. object try_match {
  2. val result_try =try{
  3. Integer.parseInt("dog")
  4. }catch{
  5. case _=>0
  6. }finally{
  7. println("always be printed")
  8. }//> always be printed
  9. //| result_try : Int = 0
  10. val code =3//> code : Int = 3
  11. val result_match=code match{
  12. case1=>"one"
  13. case2=>"two"
  14. case _ =>"others"
  15. }//> result_match : String = others
  16. }

相关文章:

  • 2021-05-10
  • 2021-11-25
  • 2021-12-24
  • 2021-05-28
  • 2022-02-27
  • 2021-07-21
猜你喜欢
  • 2022-12-23
  • 2021-11-22
  • 2021-11-22
  • 2021-11-22
  • 2022-01-07
  • 2021-11-22
相关资源
相似解决方案