Avatar
Avatar
Iceman
@swift-5.9.2 let v = if Bool.random() { "World" } else { nil } print(type(of: v)) let v2 = Bool.random() ? "World" : nil print(type(of: v2))
exit status: 1 with <stdin>:1:45: error: 'nil' requires a contextual type let v = if Bool.random() { "World" } else { nil } ^ <stdin>:2:1: error: type of expression is ambiguous without a type annotation print(type(of: v)) ^~~~~~~~~~~~~~~~~~