Run ❯
Get your own website
❯Run Code Ctrl+Alt+R
Change Orientation Ctrl+Alt+O
Change Theme Ctrl+Alt+D
Go to Spaces Ctrl+Alt+P
struct Article { let title: String; let body: String } extension Article { // Formatting helpers var preview: String { String(body.prefix(40)) + "..." } } extension Article { // Networking stub static func fetchAll() -> [Article] { [ Article(title: "A", body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), Article(title: "B", body: "Sed do eiusmod tempor incididunt ut labore.") ] } } let items = Article.fetchAll() print(items[0].preview)