Andrew Bancroft 4/22/2015

3 Nuances of Swift Extensions

Read Original

This article delves into three subtle aspects of Swift extensions that often surprise developers: (1) whether extensions can access private members of the type they extend, (2) how the extension's file location (same file vs separate file) affects that visibility, and (3) how default access modifiers and explicit specifications influence what an extension exposes as public API. Using a concrete example of a Person struct with private properties, the author clarifies common misunderstandings and provides practical insights for Swift developers. The article also references a follow-up piece on Swift access control for further reading.

3 Nuances of Swift Extensions

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet