Code Monkey home page Code Monkey logo

swift-in-60-seconds-course's Introduction

Swift in 60 seconds course playground files

Files created while working on Swift in 60 seconds course by Paul Hudson.

Contents

Simple types

Variables, Strings and integers, Multi-line strings, Doubles and booleans, String interpolation, Constants, Type annotations

Link to code

Complex types

Arrays, Sets, Tuples, Arrays vs sets vs tuples, Dictionaries, Dictionary default values, Creating empty collections, Enumerations, Enum associated values, Enum raw values

Link to code

Operators and conditions

Arithmetic Operators, Operator overloading, Compound assignment operators, Comparison operators, Conditions, The ternary operator, Switch statements, Range operators

Link to code

Looping

For loops, While loops, Repeat loops, Exiting loops, Exiting multiple loops, Skipping items, Infinite loops

Link to code

Functions

Writing functions, Accepting parameters, Returning values, Parameter labels, Omitting parameter labels, Default parameters, Variadic functions, Writing throwing functions, Running throwing functions, inout parameters

Link to code

Closures

Creating basic closures, Accepting parameters in a closure, Returning values from a closure, Closures as parameters, Trailing closure syntax, Using closures as parameters when they accept parameters, Using closures as parameters when they return values, Shorthand parameter names, Closures with multiple parameters, Returning closures from functions, Capturing values

Link to code

Structs

Creating your own structs, Computed properties, Property observers, Methods, Mutating methods, Properties and methods of strings, Properties and methods of arrays, Initializers, Referring to the current instance,Lazy properties, Static properties and methods, Access control

Link to code

Classes

Creating your own classes, Class inheritance, Overriding methods, Final classes, Copying objects, Deinitializers, Mutability

Link to code

Protocols and extensions

Protocols, Protocol inheritance, Extensions, Protocol extensions, Protocol-oriented programming

Link to code

Optionals

Handling missing data, Unwrapping optionals, Unwrapping with guard, Force unwrapping, Implicitly unwrapped optionals, Nil coalescing, Optional chaining, Optional try, Failable initializers, Typecasting

Link to code

swift-in-60-seconds-course's People

Contributors

epeuva avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

swift-in-60-seconds-course's Issues

Fix Dictionaries issue with Optionals on 2-complex-types project

Expected Behaviour

Taylor Swift height should appear on the console when executing the second exercise

// Dictionarieslet heights = [
    "Taylor Swift": 1.78,
    "Ed Sheeran": 1.73,
    "test": 200
]

// TODO: This is not fully working. Review at optional chapter
print("(print) Taylor Swift heigth: ", heights["Taylor Swift"])

// TODO: This is not fully working. Review at optional chapter
let height = heights["Taylor Swift"]! // Force unwrap of optional value
NSLog("(first NSLog) Taylor Swift heigth: %@", height)

// TODO: This is not fully working. Review at optional chapter
let height2 = heights["Taylor Swift"] ?? 0.0 // Force unwrap of optional value
NSLog("(second NSLog) Taylor Swift heigth: %@", height2)

Actual Behaviour

Optionals are not unwrapped well.

When accessing the height dictionary, an optional(1.78) appears when using print. (null) appears when using NSLog with force unwrap operator "!" or when using the nil coalescing operator "??"

Taylor Swift heigth:  Optional(1.78)
2018-07-30 12:27:48.965120+0200 2-complex-types[4130:129994] (first NSLog) Taylor Swift heigth: (null)
2018-07-30 12:27:48.965213+0200 2-complex-types[4130:129994] (second NSLog) Taylor Swift heigth: (null)

Steps to Reproduce the Problem

  1. Download the code
  2. Open 2-complex-types project
  3. Run with Xcode 9.4.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.