Hi All I am looking at Swift 2.0. The compiler has converted the code below to the “latest” Swift syntax. This causes the error shown. I have spent a few days trying to get this to compile. What is confusing to me, is that the code, listed last (func removeAnElemen…..) does compile ( all in Playground) and there 'anyGenerator' seems to tolerate some logic in the body of “anyGenerator”. Any insight will be much appreciated.
// This is OLD Swift // Generators and sequences var currentValue = 1 let newGenerator = GeneratorOf<Int> { let previousValue = currentValue currentValue = currentValue * 2 if (previousValue > 20) { return nil } return previousValue } let generatedArray = Array(newGenerator) // This is Swift 2.0 // Generators and sequences var currentValue = 1 let newGenerator = anyGenerator { // Error: Cannot find an overload for ‘anyGenerator’ that accepts an argument list of type ‘(()-> _) let previousValue = currentValue currentValue = currentValue * 2 if (previousValue > 20) { return nil } return previousValue } let generatedArray = Array(newGenerator) This does compile: func removeAnElement<T>(array: [T]) -> AnyGenerator<[T]> { var i = 0 return anyGenerator { if i < array.count { var result = array.self result.removeAtIndex(i) i++ return result } return nil } } Array(removeAnElement([1,2,3])) _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com