Skip to content

Instantly share code, notes, and snippets.

View shonorio's full-sized avatar

Solli Moreira Honorio shonorio

View GitHub Profile
import Foundation
import PlaygroundSupport
/// A thread-safe array.
public class SynchronizedArray<Element> {
private let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent)
private var array = [Element]()
public init() { }
@keybuk
keybuk / ifwhere.md
Last active February 15, 2021 07:26
Why the `where` clause in Swift's `for` loops matter

An important goal in Swift is clarity at the point of use, this appears in the API Design Guidelines as a fundamental, but also pervades the design of the Swift language itself.

I think that removing the where clause from Swift's for loops reduces clarity.

It may be that there are other ways to express the same code result, but "only one way to do it" has never been a Swift goal that I'm aware of, and an identical result does not necessarily equate to an identical intent.

Consider the following, which was actually a source of brief confusion for me while reading some of your code.

Example 1:

@romaonthego
romaonthego / NSDateFormatter cheat sheet
Last active May 3, 2024 07:26
Date Formats for NSDateFormatter
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)