Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

27.2. Class

			

    public class TextMessage {
        public String msgtype;
        public Map<String, String> text;

    }
			
		

		
	class TextMessage {
        var msgtype: String? = null
        var text: Map<String, String>? = null
    }		
		
		

27.2.1. 枚举

			
// 定义简单枚举
enum class Direction {
    NORTH, SOUTH, EAST, WEST
}

// 使用枚举
fun main() {
    val direction = Direction.NORTH
    println(direction) // 输出:NORTH
    
    // 遍历所有枚举值
    for (d in Direction.values()) {
        println(d)
    }
}