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
let a = [1, 2, 3]; | |
let [x, y, z] = a; // x = 1; y = 2; z = 3; |
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 | |
import UIKit | |
import RxSwift | |
import RxCocoa | |
let ps = PublishSubject<Int>() | |
func pt() -> String { | |
let thread = NSThread.currentThread() |
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 | |
public func delay(_ delay: TimeInterval, closure: @escaping ()->()) { | |
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { | |
closure() | |
} | |
} | |
#if NOT_IN_PLAYGROUND |
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 | |
extension String { | |
// Return a String prefix with UTF8 representation limited to at most maxBytes. If maxBytes is negative, return the original string. | |
public func prefixUTF8(maxBytes: Int) -> String { | |
if maxBytes < 0 { | |
return self | |
} | |
// Select the prefix of the string, leaving behind the remaining bytes. | |
var prefix = self.utf8.prefix(maxBytes) |