> On Apr 14, 2016, at 9:24 AM, Jens Alfke <j...@mooseyard.com> wrote: > > >> On Apr 14, 2016, at 9:00 AM, Joe Groff <jgr...@apple.com> wrote: >> >> This is a known bug. Converting arrays of value type to arrays of protocol >> type is not supported—only class covariance is supported with containers—but >> the compiler fails to catch some cases. > > Thanks for the info! > > I found that if I use AnyObject instead of Any, it does work correctly. Is > that because AnyObject isn’t a protocol? Or because conversion to AnyObject > is a ‘magic’ case that uses Obj-C bridging?
Yeah, it's magic. Int is bridged to NSNumber, so converting to an array of object type works via the bridge. -Joe > > My intuition is that [Any] will be more efficient than [AnyObject] for > primitive values like numbers, because the AnyObject conversion boxes the > value into a heap object, while converting to Any doesn’t. Or is that > incorrect? > > —Jens _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users