// 这段代码实现了java中不可能实现的功能 inline fun <reified T> getGenericType() { return T::class.java } // 测试 fun main() { val result1 = getGenericType<String>() val result2 = getGenericType<Int>() // java.lang.String println("result1 is $result1") // java.lang.Integer ...
自Kotlin 1.1 起,可以使用 enumValues<T>() 和enumValueOf<T>() 函数以泛型的方式访问枚举类中的常量。 1.4.1、访问枚举变量属性 例: fun main(args: Array<String>) { println("name = " + Color.RED.name + "\tordinal = " + Color.RED.ordinal) println("name = " + Color.WHITE.name + "...
*/ public infix fun or(other: Int): Int /** Performs a bitwise XOR operation between the two values. */ public infix fun xor(other: Int): Int /** Inverts the bits in this value. */ public fun inv(): Int public override fun toByte(): Byte public override fun toChar(): Char...
(y) returns true and y.equals(z) returns true, then x.equals(z) should return true * * Consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on ...
/** Performs a bitwise OR operation between the two values. */publicinfix funor(other:Int):Int 最后需要注意的一点是,上面的所有函数全部为顶层函数(Top Level Function),这可以方便脚本直接调用这些函数,而不需要指定命名空间。 搞到这里,其实我们的HeLangKotlinScriptImpl已经接近完成了,但是,为了方便使用,我...
//Map常用API,默认实现 – LinkedHashMap:迭代 Map 时保留元素插入的顺序val numMap =mapOf("key1"to1,"key2"to2,"key3"to3)println(numMap.keys)//[key1, key2, key3]println(numMap.values)//[1, 2, 3] 注意:在.values中调用remove()仅删除给定值匹配到的的第一个条目。println(numMap.entri...
Create a function and call it Call a function multiple times Create a function with parameters Using the return keyword in a function Short hand syntax for return values Functions Explained Kotlin ClassesCreate a class and an object of that class Create multiple objects of one class Create a ...
KT-70384 Analysis API Standalone: The same class in the same two renamed jars is unresolved KT-71067 Exceptions from references cancel Find Usages KT-69535 Redesign 'containingSymbol' KT-71025 K2 IDE: Scopes in "importingScopeContext" have reversed ordering and "indexInTower" values KT-67483 K2...
KT-53278Support values 6 and 8 for -Xjdk-release KT-46312CLI: Kotlin runner should use platform class loader to load JDK modules on Java 9+ Tools. Commonizer KT-54310Commonizer fails on 1.8.0-dev K/N distributions KT-48576[Commonizer] platform.posix.pselect not commonized in Ktor ...
Function with two parameters fun $NAME$($PARAM1$ : $PARAM1TYPE$, $PARAM2$ : $PARAM2TYPE$) : $RETURN$ { $END$ } Kotlin statement Kotlin class Kotlin top-level ifn Inserts 'if null' expression if ($VAR$ == null) { $END$ } ...