Michael Long
Nov 13, 2023

--

Another one that's useful, but painful to implement, is...

var isDog: Bool {

switch self {

case .dog,: return true

default: return false

}

}

var isCat: Bool {

switch self {

case .cat,: return true

default: return false

}

}

They've been threatening to add some sugar for this to Swift for a few years now, but...

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet