Kotlin 1.2 Language DocumentationArray, which prevents a possible runtime failure (but you can use Array , see Type Projections). Kotlin also has specialized classes to represent arrays of primitive types without boxing overhead: Kotlin doesn't have any. Instead, it has two other things: declaration-site variance and type projections. First, let's think about why Java needs those mysterious wildcards. The problem is explained CharSequence or an array of Object to the fill() function. Type projections Use-site variance: Type projections Star-projections 98 Sometimes you want to say that you know nothing about the type 0 码力 | 333 页 | 2.22 MB | 1 年前3
Kotlin Language Documentation 1.3Array, which prevents a possible runtime failure (but you can use Array , see Type Projections). Kotlin also has specialized classes to represent arrays of primitive types without boxing overhead: Kotlin doesn't have any. Instead, it has two other things: declaration-site variance and type projections. First, let's think about why Java needs those mysterious wildcards. The problem is explained copy(ints, any) // ^ type is Array but Array was expected Type projections Use-site variance: Type projections 132 Here we run into the same familiar problem: Array is invariant in 0 码力 | 597 页 | 3.61 MB | 1 年前3
Kotlin Language Documentation 1.9.20direct subclasses Sealed classes and when expression Generics: in, out, where Variance Type projections Generic functions Generic constraints Definitely non-nullable types Type erasure Underscore recommend that library authors switch to the new backend in production. 286 Invariant projections of type arguments, such as Smth<@Ann Foo>, Array<@Ann Foo>. In the following example, the @Foo possible runtime failure. Instead, you can use Array. For more information, see Type Projections. Work with arrays In Kotlin, you can work with arrays by using them to pass a variable number 0 码力 | 1299 页 | 32.44 MB | 1 年前3
Kotlin 1.9.10 官方文档 中文版
supported: Type annotations on method parameters, method return types and property types; Invariant projections of type arguments, such as Smth<@Ann Foo> , Array<@Ann Foo> . In the following example, the possible runtime failure. Instead, you can use Array. For more information, see Type Projections. 使用数组 In Kotlin, you can work with arrays by using them to pass a variable number of arguments 参见 Java Generics FAQ)。 而 Kotlin 中没有。 相反,Kotlin 有声明处型变(declaration-site variance)与类 型投影(type projections)。 我们来思考下为什么 Java 需要这些神秘的通配符。在 《Effective Java》第三 版 很好地解释了该问题—— 第 31 条:利用有限制通配符来提升 API 的灵活 性。 0 码力 | 3753 页 | 29.69 MB | 1 年前3
Kotlin 官方文档中文版 v1.9supported: Type annotations on method parameters, method return types and property types; Invariant projections of type arguments, such as Smth<@Ann Foo> , Array<@Ann Foo> . In the following example, the possible runtime failure. Instead, you can use Array. For more information, see Type Projections. 使用数组 In Kotlin, you can work with arrays by using them to pass a variable number of arguments 类型系统中最棘手的部分之一是通配符类型(参见 Java Generics FAQ)。 而 Kotlin 中没 有。 相反,Kotlin 有声明处型变(declaration-site variance)与类型投影(type projections)。 我们来思考下为什么 Java 需要这些神秘的通配符。在 《Effective Java》第三版 很好地解释了 该问题—— 第 31 条:利用有限制通配符来提升 API 的灵活性。 首先,Java 0 码力 | 2049 页 | 45.06 MB | 1 年前3
共 5 条
- 1













