How to say "the value in parent scope" in a function

I've always wanted this feature. I generally just name things uglier than I want. But that's probably a bad idea these days; practicing civil disobedience in one area of your life, working to make life look like you want it to, will help you make it a habit for where it counts more. The best way I know of to accomplish that is a struct instance.

func f() {
  struct F {
    var u: Int? = 29
  }

  var f = F()

  if let u = f.u {
    f.u = u * u
  }
}

It seems to me that this would be a nice compromise?

func f() {
  f: do {
    var u: Int? = 29

    if let u = f.u {
      f.u = u * u
    }
  }
}
1 Like