Swift enum语法

10 min read
//
//  File.swift
//  
//
//  Created by pan on 2022/11/27.
//

import Foundation


enum Phone {
    case iphone12
    case iphoneSE
    case nokia
}

func getSeansPhone(test phone:Phone){
    if(phone == .iphone12){
        print("this is my phone ")
    }else if (phone == .nokia){
        print("this is classic")
    }
}


getSeansPhone(test: .iphone12)
import Foundation


enum Phone:String {
    case iphone12 = "next"
    case iphoneSE = "good"
    case nokia = "classic"
}

func getSeansPhone(test phone:Phone){
    print(phone.rawValue)
}


getSeansPhone(test: .iphone12)