Group Group Group Group Group Group Group Group Group

Chapter 13 - Repeated Local Variables in Path Method

Hi All,

Looking at the final version of the rewards view “AirportMealAward.swift” in chapter 13. The local variables for each Path closure use the same local variables.

      let size = min(geometry.size.width, geometry.size.height)
      let nearLine = size * 0.1
      let farLine = size * 0.9

Is there a way to create these at a top level, so they are not repeated. I can’t seem to figure this out.

It’s not a requirement of the chapter but just wanting to know…

Thanks.

Not really. About the best alternative can do in SwiftUI now is to define a function to wrap the calculations. That’s one of the things I hope to see in the next version.