-
子类可数(枚举是实例可数)
-
<v1.1子类必须定义为密封类得内部类
-
v1.1子类只需要与密封类在同一个文件夹中
code
package com.yzdzy.kotlin.SealedClass
sealed class PlayerCmd {
class Play(val url: String, val position: Long = 0) : PlayerCmd()
class Seek(val position: Long = 0) : PlayerCmd()
object Pause : PlayerCmd()
object Resume : PlayerCmd()
object Stop : PlayerCmd()
}
enum class PlayerStae {
IDLE, PAUSE, PLAYING
}
来源:oschina
链接:https://my.oschina.net/u/4321566/blog/4316306