Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • ok, i thought about this solution too, but explain me, why i cannot acces with h.huh.innerVal? Commented Jun 4, 2014 at 20:04
  • Swift is type-safe and the only thing the external world knows about h is that it complies to HuhThing. HuhThing does not include any information about a property called innerVal and so attempting to access it is an error. Commented Jun 4, 2014 at 20:14
  • 8
    Still accessible :P reflect(h)[0].1.value // 19 Commented Jun 6, 2014 at 7:55
  • 2
    Nice find there John - I wasn't aware of reflect. Seems to turn objects into Tuples - is there any official documentation on that function or other metaprogramming stuff in Swift? I took a look through the language guide on iBooks but I'm not seeing it. Commented Jun 6, 2014 at 21:23
  • 1
    @JohnEstropia I don't think reflection counts. In Java (a more mature language), there are access modifiers, but they don't prevent reflection tricks either. Commented Jun 11, 2014 at 9:13