Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

swift-enum #194

Open
platojobs opened this issue May 8, 2022 · 0 comments
Open

swift-enum #194

platojobs opened this issue May 8, 2022 · 0 comments
Labels
MobileDevelopment iOS、安卓、Flutter、go

Comments

@platojobs
Copy link
Owner

platojobs commented May 8, 2022

enum UGCContent {
    
    case west
    case east
    
    func desp() {
        print("hello")
    }
    
    static func ugcFun(){
        print("static")
    }
}

var rt = UGCContent.east
rt.desp()
UGCContent.ugcFun()

enum Weekday: String, CaseIterable {
  case sunday, monday, tuesday, wednesday, thursday, friday, saturday

  /* 自动合成的实现
  static var allCases: Self.AllCases { [sunday, monday, tuesday, wednesday, thursday, friday, saturday] }
  */
}

let weekday = Weekday.allCases.map{ $0.rawValue}.joined(separator: ",")
print(weekday)

//对于有关联值的枚举,不会自动合成 allCases,因为关联值没法确定
@platojobs platojobs changed the title 😄 1 Jul 22, 2022
@platojobs platojobs changed the title 1 swift-enum Mar 12, 2024
@platojobs platojobs added the MobileDevelopment iOS、安卓、Flutter、go label Mar 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
MobileDevelopment iOS、安卓、Flutter、go
Projects
None yet
Development

No branches or pull requests

1 participant