|  |      1ysc3839      2024-03-19 19:43:23 +08:00 via Android return 也会执行 | 
|      2google2020      2024-03-19 19:45:12 +08:00  1 try 或 catch 可以 return ,return 之后外面的就不跑了,但 final 会照样跑 | 
|      3mxT52CRuqR6o5      2024-03-19 19:45:44 +08:00 其他语言不清楚,js 的 final 块可以改变 try/catch 中已经 return 的返回值 | 
|  |      4geelaw      2024-03-19 20:07:37 +08:00  1 楼上已经说过 return 的时候 finally 会执行,把必须执行的代码写在 finally 里面而不是后面对阅读更好。另外就是 try { throw something; } catch { throw; } // 重新 throw finally { other; } another; 里面 other 是会执行的,another 不会执行。当然你可以说 another 可以挪到最外面的 catch 后面,但是这样会导致整个程序不能非平凡地使用方法,因为最外面的 catch ,在一段“正常书写”的代码里,不一定在当前方法里面。 |