This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Student { | |
let firstName : String | |
let lastName : String | |
} | |
extension Student : Hashable { | |
static func == (lhs: Student, rhs: Student) -> Bool { | |
return lhs.firstName == rhs.firstName && lhs.lastName == rhs.lastName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
// Arrays are ordered collections of values. | |
// Sets are unordered collections of unique values. | |
// Dictionaries are unordered collections of key-value associations. | |
(print("\n=== ARRAY SECTION ===\n")) | |
// Create empty array of strings | |
var stringArray = [String]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
gitlab: | |
container_name: gitlab | |
image: gitlab/gitlab-ce:latest | |
restart: always | |
environment: | |
GITLAB_OMNIBUS_CONFIG: | | |
## GitLab configuration settings | |
##! Check out the latest version of this file to know about the different |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
// nhathm01247@gmail.com | |
import Foundation | |
import UIKit | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
class Worker: NSObject { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getDataFromServer(url: String, completion: @escaping (String?) -> ()) { | |
// | |
} | |
getDataFromServer(url: "http://0.0.0.0:8888/test") { (response) in | |
// | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
// nhathm01247@gmail.com | |
import Foundation | |
import UIKit | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
class ServerConnection: NSObject { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
// nhathm01247@gmail.com | |
import Foundation | |
// Requirement: write a function take Int, Int, Int and a function that sum first two Int params and then sub the third Int. | |
// Do it function way | |
// Declare a function | |
func add(_ a: Int, _ b: Int) -> Int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
// nhathm01247@gmail.com | |
import Foundation | |
/** DECLARE A CLOSURE **/ | |
// Declare a variable to hold a closure | |
var add: (Int, Int) -> Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare a variable to hold a closure | |
var add: (Int, Int) -> Int | |
/** SHORTHAND SYNTAX **/ | |
// Not need return keyword when only have single return statement | |
add = {(a: Int, b: Int) -> Int in | |
a + b | |
} | |
add(1, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Declare a variable to hold a closure | |
var add: (Int, Int) -> Int | |
// Assign a closure to a variable | |
add = { (a: Int, b: Int) -> Int in | |
return a + b | |
} |