<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 10, 2016, at 6:01 PM, Milos Rankovic <<a href="mailto:milos@milos-and-slavica.net" class="">milos@milos-and-slavica.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">As I already stressed, I certainly do not imagine this to be “Swift-specific”, nor do I see any reason it would need to be. </div></div></blockquote><div><br class=""></div><div>It sounds like you’re asking for a `sample` property to be added to NSArray, NSDictionary, NSSet, etc. You could certainly request that Apple do that, by filing a request at <a href="http://bugreport.apple.com" class="">http://bugreport.apple.com</a>, but don’t expect a reply; Apple’s framework teams are notoriously opaque.</div><div><br class=""></div><div>Putting on my framework-designer hat, I’d argue that “random” is a broad concept with several possible implementations. Which RNG does `sample` use? Pick a cryptographic one and it might be too slow for some use cases; pick a fast one and it'd be insufficiently random, making it dangerous to use for anything related to security. The right answer might be to have a RNG protocol, with several implementations backed by different generators, that exposes a method like `randomElement(Collection)`.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Also, it looks like you’ve missed my previous email in this thread where I give examples of current Foundation extensions of Standard Library types, and where I also make the bare bones of my wish-list rather more explicit.</div></div></blockquote></div><br class=""><div class="">The way those are implemented is a weird hack, so they’re not actually good examples of what you’re asking for. </div><div class=""><br class=""></div><div class="">It’s not that Apple's Foundation framework contains any extensions to Swift; Foundation is lower-level and I don’t believe it has any knowledge at all of Swift. So this is <i class="">not</i> the same effect as when you import a Swift library to get extensions. Rather, importing Foundation is a hardwired signal to the Swift compiler to activate the implicit bridging between Swift’s String class and Foundation’s NSString (and likewise for Array/NSArray, etc.)</div><div class=""><br class=""></div><div class="">In Swift 3 this will supposedly change: these APIs will be added directly to the Swift classes, removing the need for bridging.</div><div class=""><br class=""></div><div class="">—Jens</div></body></html>