/swift-by-example

Quick reference for Swift on Linux

Primary LanguageCSS

Swift by Example

Build Status Swift 4.2

Inspired by Go by Example. Aimed to give an overview for common things in the standard library and Foundation. All examples should work on Linux using the latest version of the Swift compiler. Documentation for macOS- or iOS-specific APIs is a non-goal.

These are the things that I want to add at some point:

  • closures (+ @autoclosure)
  • parameters (mutability, inout)
  • Builtin datastructures (arrays, dictionaries, sets, strings)
  • Common protocols (printable, debugprintable)
  • Custom literals
  • Reading/writing files
  • TCP sockets (+ udp)
  • HTTP client
  • Threads?
  • Pattern matching
  • Structs & classes
  • Reading methods
  • CLIs + user input
  • Serialisation (JSON/YAML/plist/???)
  • Custom operators
  • Overriding operators
  • @dynamicMemberLookup
  • debugging with lldb
  • generic functions
  • generic structures
  • Parsing URLs
  • Hashing (SHA1, MD5)
  • Base64 encoding/decoding
  • Reading environment variables
  • Working with dates & times
  • Working with Strings (& Index)
  • extensions (& protocol extensions)
  • computed properties, didSet, willSet
  • Errors
  • Collection functions
  • guard
  • Random numbers
  • Tuples
  • typealiases
  • Subprocesses
  • Reflection
  • enums (with initialisers and associated values)