我在看android4.2新API说明的时候,看到了 UserManager类,其中有一个isUserAGoat ()方法:
public boolean isUserAGoat ()
Used to determine whether the user making this call is subject to teleportations.
Returns whether the user making this call is a goat.
请问这个isUserAGoat ()方法是怎么用的?
应该是未来要用的某个特殊方法,目前全部都是返回false的。
/**
* Used to determine whether the user making this call is subject to
* teleportations.
* @return whether the user making this call is a goat
*/
public boolean isUserAGoat() {
return false;
}
虽然我不知道这算不算得上是“正式用法”,但是下面的代码会在java中引发警告(这种警告在后期编码中如果遇到return语句就可以引发编译错误):
if(1 == 2) {
System.out.println("Unreachable code");
}
但是换成下面的代码就正常:
if(isUserAGoat()) {
System.out.println("Unreachable but determined at runtime, not at compile time");
}
所以我发现经常会为了最快的虚拟出一个代码块就用一些笨方法,然后在整个调试中找到所有对它的调用,这样来提供不会改变这个的实现方法来使用。