Skip to content

Instantly share code, notes, and snippets.

View mahmudahsan's full-sized avatar

Mahmud Ahsan mahmudahsan

View GitHub Profile
var x // error
var x:Int // okay
var score:Int?
score = 100
//if score is nil the if block will not work
/*if score has value, the if block create a new constant score and assign the score value to the new constant score which is unwrapped and available within the if block
*/
if let score = score{
score
}
score ?? 0 //provide a default value when there is nil
score! //when u sure the optional must have a value other than nil
import UIKit
import PlaygroundSupport
//to run serial queue in playground always make the following true
PlaygroundPage.current.needsIndefiniteExecution = true
let mainQueue = DispatchQueue.main
let globalQueue = DispatchQueue.global()
let serialQueue = DispatchQueue(label: "net.ithinkdiff.app")
let concurQueue = DispatchQueue(label: "net.ithinkdiff.app.concurr", attributes: .concurrent)