Skip to content

Instantly share code, notes, and snippets.

View KanshuYokoo's full-sized avatar

kkaannnssshh KanshuYokoo

View GitHub Profile
@KanshuYokoo
KanshuYokoo / SwiftUIArcView.swift
Created April 2, 2020 12:21
SwiftUI shape Example, Arc
import SwiftUI
struct ArcView: View {
var body: some View {
Arc(startAngle: .degrees(0), endAngle: .degrees(110), clockwise: true)
.stroke(Color.blue, lineWidth: 5)
.frame(width: 300, height: 300, alignment: .center)
}
}
@KanshuYokoo
KanshuYokoo / Sequence+keypathUtils.swift
Created April 13, 2020 16:31
utilities with swift keypath, sorting, map, min, max
extension Sequence {
func sorted<T: Comparable>(by keyPath:KeyPath<Element, T>) -> [Element]{
return sorted {a, b in
return a[keyPath: keyPath] < b[keyPath:keyPath]
}
}
func map <T> (_ keyPath: KeyPath<Element, T>) -> [T] {
return map {$0[keyPath: keyPath]}
}