قالب وردپرس درنا توس
Home / Apple / Michael Tsai – Blog – Inline Types and Features in Swift

Michael Tsai – Blog – Inline Types and Features in Swift



John Sundell:

Inlining can be a good tool for situations when we need an extra type or function, but we do not want to expose it beyond the scope it is used for. By placing that kind of easier, narrower scoped, types and features right next to the code that uses them – we can also make the code easier to navigate and work with, by reducing context switching.

The fact that we can choose to define types and function not only at the top level of a program but also inline within other types or functions is another example of how flexible Swift is in terms of structure and syntax. But, as with other functions of the same nature, it is important not to take things too far.

I really like using nested statements and access control modifiers to make the code more readable. One drawback is that this can make the pile tracks less readable because they lacked the names end up longer than if you had chosen a globally unique name.

Programming Swift Programming Language

Keep up to date by subscribing to the comments RSS feed for this post.


Source link