gpt4 book ai didi

Scala 函数式编程 : Should I use 'throw' or 'throw new' ?

转载 作者:行者123 更新时间:2023-12-02 08:15:10 32 4
gpt4 key购买 nike

<分区>

在 Scala 中进行一些函数式编程,并且来自 Java 背景,我倾向于像这样抛出异常:

throw new MyException("something is wrong")

但是,我也看到有人省略了 new:

throw MyException("something is wrong")

哪种方式更地道?

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com