Throwing exception vs returning null value with switch statement

前端 未结 4 2088
名媛妹妹
名媛妹妹 2021-02-18 21:40

So I have function that formats a date to coerce to given enum DateType{CURRENT, START, END} what would be the best way to handling return value with cases that use switch stat

4条回答
  •  名媛妹妹
    2021-02-18 22:33

    Exceptions, as you can obey more to the parent than a single return int can. Usually you use Exceptions where they exist (C++), and return values where not (C).

提交回复
热议问题