我先来,引用别人的 jar 包时,看到源码还能这么玩。。。
if (deviceInfoModel == null || (deviceInfoModel.getDevices() == null || deviceInfoModel.getDevices().size() == 0)) {
try {
throw new DeviceNotFoundException("Android Device Not Found !!!");
} catch (DeviceNotFoundException e) {
System.err.println(e.toString());
}
}
这 throw 了又 catch,秀操作呢?!
大伙说说遇到过的惊艳代码,任何语言都可以
1
cjh1095358798 2020 年 7 月 6 日
感觉很牛皮啊
|
2
neroransom 2020 年 7 月 7 日 via Android
层 层 外 包
|
3
drizztdu 2020 年 7 月 7 日 via iPhone
手动套娃
|
4
Still4 2020 年 7 月 7 日
我见过这么用的,人家给我的解释是需要知道堆栈
|
5
matepi 2020 年 7 月 7 日
如果 if 内部是个异常处理的通用做法,这个很可以理解
但这个就是个 throw……要么就是准备以后写成通用做法,暂且这样写,后面便于批量找到后重构吧 ……编不下去了 |
6
timothyye 2020 年 7 月 7 日 左手抛出异常,右手立马接住,把异常玩弄于鼓掌之间
|
7
LongMaoz 2020 年 7 月 7 日
一朋友的:
if(res.data.Msg === "成功"){ message.Show("成功") } |
8
supuwoerc 2020 年 7 月 7 日
我看到过这样的:
` if(a===true){ a=false; }else{ a=true; } ` |
10
ragnaroks 2020 年 7 月 7 日
csharp 的
public async Task ActionAsync(){ // } public async Task Invoke(){ await Task.run(async()=>{ await this.ActionAsync(); }); } |
11
ragnaroks 2020 年 7 月 7 日
好像被 trim 了,csharp 的
public async Task ActionAsync(){ ____// } public async Task Invoke(){ ____await Task.run(async()=>{ ________await this.ActionAsync(); ____}); } |
13
wmhx 2020 年 7 月 7 日
检测一个字符串是不是数值, 最简单的方法不就是 Integer.valueof() 看有没有异常么?
|
14
35aZ4P8mT576683q 2020 年 7 月 7 日
interface Status {
success: boolean; failure: boolean; } const result: Status = { success: true, failure: false } if (!data) { result.success = false; result.failure = true; } //Typescript 代码,如何把布尔值复杂化 //为了可以用 const 关键字不择手段 |
15
bigNewsMaker 2020 年 7 月 7 日 via iPhone
#define ";" ";"
|
16
Anarchy 2020 年 7 月 7 日
我猜啊,可能原来是需要打印堆栈的,后来改了
|
17
Ahaochan 2020 年 7 月 8 日
public class PrivilegeProvider {
public String selectById(final Long id){ return new SQL(){ { SELECT("id, privilege_name, privilege_url"); } }.toString(); } } Mybatis 的源码,第一次看时居然没有看懂. https://blog.ahao.moe/posts/Ignored_initialization_block.html |
18
122006 2020 年 7 月 31 日
new DeviceNotFoundException 里有逻辑呗。。。。
|