小编jdd*_*dxf的帖子

Java三元运算符vs <JDK8兼容性中的if/else

最近我正在阅读Spring Framework的源代码.我无法理解的东西在这里:

public Member getMember() {
    // NOTE: no ternary expression to retain JDK <8 compatibility even when using
    // the JDK 8 compiler (potentially selecting java.lang.reflect.Executable
    // as common type, with that new base class not available on older JDKs)
    if (this.method != null) {
        return this.method;
    }
    else {
        return this.constructor;
    }
}
Run Code Online (Sandbox Code Playgroud)

此方法是类的成员org.springframework.core.MethodParameter.代码很容易理解,而评论很难.

注意:即使使用JDK 8编译器,也没有三元表达式来保持JDK <8的兼容性(可能选择java.lang.reflect.Executable为通用类型,旧的JDK上没有新的基类)

if...else...在这种情况下使用三元表达和使用构造有什么区别?

java ternary-operator java-8

112
推荐指数
4
解决办法
1万
查看次数

in关键字在打字稿中起什么作用?

我知道如何使用它,但是我在文档中找不到任何解释。我想要一个准确的定义,以便我可以更好地理解它。

编辑:我的意思是in用于映射类型,而不是js运算符。

typescript

15
推荐指数
1
解决办法
3806
查看次数

标签 统计

java ×1

java-8 ×1

ternary-operator ×1

typescript ×1