1. Swift / Говнокод #24431

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    @dynamicMemberLookup
    struct Uppercaser {
        subscript(dynamicMember input: String) -> String {
            return input.uppercased()
        }
    }
    
    Uppercaser().hello // → "HELLO"
    // You can type anything, as long as Swift accepts it as an identifier.
    Uppercaser().käsesoße // → "KÄSESOSSE"

    https://oleb.net/blog/2018/06/dynamic-member-lookup

    The proposal and implementation of dynamic member lookup was largely driven by the Swift for TensorFlow team at Google. Their main motivation is to facilitate interoperability between Swift and dynamic languages, specifically (though not exclusively) Python. Their goal is to make it possible to call Python code from Swift with a pretty and familiar syntax.

    We need MOAR syntax sugar

    Запостил: Desktop, 30 Июня 2018

    Комментарии (21) RSS

    Добавить комментарий