[swift-users] Sampling collections

Milos Rankovic milos at milos-and-slavica.net
Sun Apr 10 06:50:03 CDT 2016

In the playground:

    "works?".capitalizedString // error: value of type 'String' has no member 'capitalizedString'

… but:

    import Foundation
    “works!”.capitalizedString // “Works!” 

Would it not be nice if all the following likewise worked:

    import Foundation
    ["a": 1, "b": 2, "c": 3].sample

Like so many users of Swift, I have extensions <http://stackoverflow.com/a/30285125/1409907> of IntegerType, ClosedInterval and CollectionType that avail me of the above methods and their family, but I’d much rather if such extensions came with Darwin or at least Foundation.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160410/6145a4dc/attachment.html>

More information about the swift-users mailing list