Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftphantom typesSingle-choice MCQ

A team uses phantom types to track units of measure at compile time. Given the setup below, which statement is true about the `add` function and the call site?

struct Meters {} struct Feet {} struct Distance<Unit> { let value: Double init(_ value: Double) { self.value = value } } func add<U>(_ a: Distance<U>, _ b: Distance<U>) -> Distance<U> { Distance(a.value + b.value) } let a = Distance<Meters>(5) let b = Distance<Feet>(3) // let c = add(a, b)