Skip to content

Instantly share code, notes, and snippets.

@jasonnoble
Created February 11, 2016 16:16
Show Gist options
  • Select an option

  • Save jasonnoble/05d84f5ddcc00c437a57 to your computer and use it in GitHub Desktop.

Select an option

Save jasonnoble/05d84f5ddcc00c437a57 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
// 1) Using git on the command line, how do you tell if there are
// changes on a remote?
// git fetch [remote]
// 2) How do you retrieve the changes?
// git pull
// 3) What is Github and what is it used for?
// Commercial website that hosts git repos. Useful for sharing,
// and collaborating on code
// 4) What is the syntax for declaring a constant named "foo" and
// setting it equal to 42?
let foo = 42
// 5) What is the syntax for declaring an optional String variable named "bar"?
var bar:String?
// 6) Write a function that takes two integers and returns an integer after
// adding them together
func add(num1:Int, num2:Int) -> Int {
return num1 + num2
}
add(3,num2: 5)
// 7) Write a function that takes two optional integers and returns an optional
// integer. It adds the params together and returns the result, if they exist.
func addOpt(num1:Int?, num2:Int?) -> Int? {
var result:Int?
if let num1 = num1,
num2 = num2 {
result = num1 + num2
}
return result
}
addOpt(5, num2: 3)
var num1:Int? = 5
var num2:Int?
addOpt(num1, num2: num2)
// 8) Devine Class and Instance and how we use each in Swift
// A Class is a blueprint for an object, including properties, super classes, etc
// An Instance is a instantiated object of a Class
// 9) What are the 3 Swift collection types? What distinguishes each?
// Array - Elements are stored at a specific index, starting at 0
// Dictionary - Elements are stored at a non-numerical index, random ordering
// Set - Elements are stored at a non-numerical index, no duplicate values
// 10) Name 5 online resources one can get quality information on developing Swift for iOS
// Ray Wenderlich (raywenderlich.com/category/swift)
// http://masilotti.com/ (UI Testing, Swift Testing)
// https://developer.apple.com/swift/resources/ (Apple docs)
// https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2-ID1 (Apple Swift book)
// Big Nerd Ranch (https://www.bignerdranch.com/blog/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment