Using closure in function scope to make "real" private class members

forkit forkit at gmail.com
Thu Jun 9 06:36:06 UTC 2022


On Thursday, 9 June 2022 at 06:21:08 UTC, forkit wrote:
>

another example, where I think swift done it better:

i.e. you know exactly what the designers intentions were when 
this was written.

(in Swift 4, an class extension can now access a private member)

-- some file --
class A { private var name = "First Letter" }

extension A
{
   func printName()
  {
    print(name) // you may access it here from swift 4. Swift 3 
will throw error.
  }
}
-- end file --



More information about the Digitalmars-d mailing list