0
let company : String? // = nil

if company == nil {
   var newCompany = company ?? "apple"
}

In this code identifier company we need to assign as let company : String? = nil but apple documentation is telling that no need for assigning nil value

SRIKANTH
  • 15
  • 3

1 Answers1

2

You declared a constant without a value and without an initializer that can change it, which is nonsensical. The compiler, therefore, warns you that you should initialize the constant.

Change let to var and your code will work fine.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223