Assert 断言 使用简列及注意点
assert 不仅是个报错函数,其表达的意思就是,程序在我的假设条件下,能够正常良好的运作,其实就相当于一个 if 语句,但是更加简洁;
示例:
@GetMapping("test_assert")
public String testAssert(Integer id){
Assert.isTrue(id<=0,"id 非法");
Country country = countryService.getById(id);
return
原创
2020-07-31 19:46:15 ·
304 阅读 ·
0 评论