escalier-lang / escalier-next

Improved type safety with tight TypeScript interop
https://escalier-lang.github.io/escalier-next/
MIT License
14 stars 0 forks source link

initialization with literals #237

Open kevinbarabash opened 6 months ago

kevinbarabash commented 6 months ago

https://developer.apple.com/documentation/swift/initialization-with-literals

struct OrderedSet<Element: Hashable>: Collection, SetAlgebra {
    // implementation details
}

extension OrderedSet: ExpressibleByArrayLiteral {
    init(arrayLiteral: Element...) {
        self.init()
        for element in arrayLiteral {
            self.append(element)
        }
    }
}

var foo: OrderedSet<Int> = [1, 2, 3]

This can be used with all literal types. It does mean that the code generator