KSP(编译时注解)封装注解:Title、OnClickFirstDrawable、OnClickFirstText、OnClickSecondDrawable、OnClickSecondText、Prefs、PrefsField、StatusBar、FlowError、GlobalConfig、ServiceApi 封装工具扩展类:CalendarExt、ContextExt、DateEx
AI代码解释 for(int i=1;i<=10;i++){}for(int i=1;i<10;i++){}for(int i=10;i>=0;i--){}for(int i=1;i<=10;i+=2){}for(int i=10;i>=0;i-=2){}for(String item:collection){}for(Map.Entry<String,String>entry:map.entrySet()){} Kotlin 代码语言:javascript 代码运行次数:...
.let(String::toBoolean)returnif(executionStrategy==IN_PROCESS_EXECUTION_STRATEGY||isGradleDaemonUsed==false){compileInProcess(messageCollector)}else{compileOutOfProcess()}} 这里kotlin编译自身有三种策略,分别是 守护进程编译 Android编译的默认模式,只有这种模式才支持增量编译 进程内编译, 进程内编译 进程外编...
values()returns the enum constants in the form of an array over which we can iterate to retrieve each enum constant.values()以数组的形式返回枚举常量,我们可以在该数组上进行迭代以检索每个枚举常量。 valueOf()is used to fetch an enum constant using a String as the argument.valueOf()用于使用Str...
fun foo2(str : String?): String? { //do-something return null } 使用let、run、apply、also等内联函数,尤其是在“链式调用”写法的时候,一定要当心它们的返回值。 扩展:什么是内联函数? 所谓内联函数就是指函数在被调用的地方直接展开,编译器在调用时不用像一般函数那样,参数压栈,返回时参数出栈以及资...
Enumsin Kotlin make handling constants type-safe, less error-prone, and self-documented. In this tutorial, we’ll explore how to convert a string into an enum object. 2. Introduction to the Problem As usual, let’s understand the problem through an example. Let’s say we have the enum ...
创建人 */ private String createBy; /** * Update人;Update人 */ private String updateBy; /** * 是否Delete;是否Delete */ @LogicDelete(strategy = LogicDeleteStrategyEnum.BOOLEAN) private Boolean deleted; } @Data @Table("t_topic") @EntityProxy //or @EntityFileProxy @ToString public class ...
enum class Direction { NORTH, SOUTH, WEST, EAST // 每个枚举常量都是一个对象, 用逗号分隔 }相比于字符串常量,使用枚举能够实现类型安全。枚举类有两个内置的属性:public final val name: String public final val ordinal: Int分别表示的是枚举对象的值跟下标位置。例如上面的Direction枚举类,它的枚举对象的...
// 类似于Java中的public static void main(String[] args){} // kotlin中存在两种main方法的写法,都可以 // var相当于是一个变量 val对比java中相当于是final修饰的变量,不允许修改 fun main(){ var intNum = 100 } fun main(args: Array<String>){ ...
// when语句 when(x) { // WARNING: [NON_EXHAUSTIVE_WHEN] 'when' expression on enum is recommended to be exhaustive, add 'OFF' branch or 'else' branch instead Mode.ON -> println("ON") // case 是一个语句 } Kotlin 1.6 起,当你在 When语句 中是可穷举类型时必须处理所有分支,不能遗漏。