标签:break lang case else enum 方法 func mem ase
// 定义方法
enum name {name1, name2, name3, ...}
二.枚举的使用
enum Sex { MALE, FEMALE, UNKNOWN } let member_sex:Sex = Sex.FEMALE; console.log(member_sex); // console.log(Sex[member_sex]); // FEMALE console.log(checkSex(member_sex)) // 女 function checkSex(sex: Sex) { let result: string = ‘‘; switch (sex) { case Sex.MALE: result = ‘男‘; break; case Sex.FEMALE: result = ‘女‘; break; case Sex.UNKNOWN: result = ‘未知‘; break; default: break; } return result; }
标签:break lang case else enum 方法 func mem ase
原文地址:https://www.cnblogs.com/smdb/p/12115503.html