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
enum FootballClubs { | |
case fenerbahce | |
case besiktas | |
case galatasaray | |
var championshipTitleCount: Int { | |
switch self { | |
case .fenerbahce: 28 | |
case .besiktas: 21 | |
case .galatasaray: 24 |
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 result = if IamNewIfElse { true } else { false } |
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 result = IamTernary ? true : false |
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 result: Bool | |
if IamOldIfElse { | |
result = true | |
} else { | |
result = false | |
} |
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 School: Hashable, Equatable { | |
let name: String | |
let state: String | |
} | |
let firstSchool = School(name: "JohnFKennedy School", state: "WA") | |
let secondSchool = School(name: "JohnFKennedy School", state: "OR") |
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 oldRegex = /\b[A-Za-z][A-Za-z0-9]{2,15}\b/ | |
let newRegex = Regex { | |
Anchor.wordBoundary | |
CharacterClass( | |
("A"..."Z"), | |
("a"..."z") | |
) | |
Repeat(2...15) { | |
CharacterClass( |
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 RegexBuilder | |
class MyRegexTutorial { | |
let text = """ | |
Regular expressions, also known as regexes, are a powerful \ | |
tool for matching patterns in text. Swift supports several \ | |
ways to create a regular expression, including from a string, \ | |
as a literal, and using this DSL. | |
""" |
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 createObservable() { | |
Observable<Int>.interval(.milliseconds(300), scheduler: MainScheduler.instance) | |
.map { [weak self] in | |
self?.multiplyByTwo(number: $0) ?? -1 | |
} | |
.subscribe { result in | |
print(result) | |
} | |
.disposed(by: disposeBag) | |
} |
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 RxSwift | |
class RxSwiftTestViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
RxSwiftTest() | |
} | |
} |
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
class RxSwiftTestViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
Observable<Int>.interval(.milliseconds(300), scheduler: MainScheduler.instance) | |
.subscribe { event in | |
print(event) | |
} | |
} |
NewerOlder