.next() enum swift

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

Also in Swift: