congrooelpsy

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

学习了kotlin基本语法

一切都是类

val, var;

Int, Long, Short, Float .....

单行函数简写

if(), for(x in y)

when(x){

  .. -> ..;

  .. -> ..;

}

when(x){

  is .. -> ..;

  is.. -> ..;

}

(a < b)

[a,b] <==>  a..b

{b, b - 1, b - 2 ... , a} <== > b downTo a  (可以结合step k, 每k部一跳)

[a,b) <==> a until b

 

kotlin 没有 new

class Student : Person()      继承(必须是open class Person, 只能继承一个)

class Student: Person         继承(有次构造函数的情况下没有显式定义主构造函数时无括号)

 

interface Study        接口

插卡式是、Student(.....) : Study   (实现接口无括号,可以实现多个)

posted on 2021-05-13 20:20  congrooelpsy  阅读(29)  评论(0)    收藏  举报