有没有办法忽略'Unreachable statement'错误? [英] Is there a way to ignore the 'Unreachable statement' error?

查看:256
本文介绍了有没有办法忽略'Unreachable statement'错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能以某种方式忽略此错误吗?我发现将返回放在我不想运行的代码前面比评论它更容易(当评论重叠并表现不好时)......

Is it possible to somehow ignore this error? I find it much easier to just put return in front of the code I don't want to run than to comment it (when the comments overlap and behave badly)...

推荐答案

不。这是一个编译时错误。所以你必须在运行你的课程之前摆脱它。

No. It's a compile time error. So you must get rid of it before running your class.

我通常做的是假的如果在它前面的声明。类似于:

What I usually do is put a fake if statement in front of it. Something like:

if(true)
    return;
// unwanted code follows. no errors.
i++;
j++;

使用此代码,您将无法获得无法到达的声明错误。你会得到你想要的东西。

With this code, you will not get a Unreachable statement error. And you will get what you want.

这篇关于有没有办法忽略'Unreachable statement'错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆