Skip to content

Instantly share code, notes, and snippets.

View hasancanakgunduz's full-sized avatar

Hasancan Akgündüz hasancanakgunduz

  • Turkcell
  • İstanbul
View GitHub Profile
@hasancanakgunduz
hasancanakgunduz / NewSwitch.swift
Created December 10, 2023 17:02
NewSwitch.swift
enum FootballClubs {
case fenerbahce
case besiktas
case galatasaray
var championshipTitleCount: Int {
switch self {
case .fenerbahce: 28
case .besiktas: 21
case .galatasaray: 24
@hasancanakgunduz
hasancanakgunduz / NewIfElse.swift
Created December 10, 2023 16:24
NewIfElse.swift
let result = if IamNewIfElse { true } else { false }
@hasancanakgunduz
hasancanakgunduz / Ternary.swift
Created December 10, 2023 16:20
Ternary.swift
let result = IamTernary ? true : false
let result: Bool
if IamOldIfElse {
result = true
} else {
result = false
}
@hasancanakgunduz
hasancanakgunduz / Hashable.swift
Created July 9, 2023 08:49
Hashable vs Equatable
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")
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(
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.
"""
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)
}
import RxSwift
class RxSwiftTestViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
RxSwiftTest()
}
}
class RxSwiftTestViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Observable<Int>.interval(.milliseconds(300), scheduler: MainScheduler.instance)
.subscribe { event in
print(event)
}
}