There seems to be a bug in Swift Playground with the use of NSCountedSet.
This code works as intended
let numbers = [1,2,2,4,6,7,8,8,5,8,1]
let set
Update: As @carbo18 reported, this has been fixed in Xcode 6.3 beta 4.
Old answer: That definitely looks like a bug. NSCountedSet
has initializers
convenience init(array: [AnyObject])
convenience init(set: NSSet)
but
let b1 = NSCountedSet(array: []) // extra argument 'array' in call
let b2 = NSCountedSet(set: NSSet()) // extra argument 'set' in call
both fail to compile.
This was also reported in the Apple Developer Forum (https://devforums.apple.com/message/1081850#1081850), where the following workaround is given:
let numbers = [1,2,2,4,6,7,8,8,5,8,1]
let bag = NSCountedSet()
bag.addObjectsFromArray(numbers)