Answers for "swift set enum type with name"

1

swift change enum value

enum SimpleEnum{
    case big(String)
    case small(String)
    case same(String)

    mutating func adjust() {
        switch self{
        case let .big(name):
            self = .big(name + "not")
        case let .small(name):
            self = .small(name + "not")
        case let .same(name):
            self = .same(name + "not")
        }
    }
}

var test = SimpleEnum.big("initial")
test.adjust()

switch test {
case let .big(name):
    print(name) // prints "initialnot"
case let .small(name):
    print(name)
case let .same(name):
    print(name)
}
Posted by: Guest on March-20-2020
0

swift ns_enum generic name

let a = 5
Posted by: Guest on September-26-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language