Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

.next() enum swift

enum Fruits: CaseIterable {
    case apple, banana, pitahaya, cherry
    
    mutating func loopme() {
        let a = Self.allCases
        self = a[(a.firstIndex(of: self)! + 1) % a.count]
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #enum #swift
ADD COMMENT
Topic
Name
7+7 =