This is a challenge for the people using Swift 2.0 beta 6, it's not code golf, but it's a programming puzzle so I'm pretty sure this belongs here. The basic idea is: Make it compile. There are more details and a very nicely formatted playground at the Github project. Previous challenges are there as well, all set up to tinker. Solutions are included for the previous challenges, as they all have been solved.
Rules
- You can't modify the given lines
- You can't insert anything between the given lines
- You can't provide custom functions for ones that are in the standard library, according to the syntax-hightlighed picture. This applies to the inverse as well.
- The given lines are not allowed to produce a warning (on default warning settings). However the code you append is allowed to produce warnings.
- The code may or may not crash at runtime, it only has to compile
The Code
func doIt(inout s: D) {
if case self = isUniquelyReferenced(&s),
self.`self` = true where self {
self.`self` = { [unowned x = [self, 7] as Self] n in
print(x + n)
} as () -> ()
}
}
The Picture
Winner
The first one posting an answer that compiles and conforms to all the rules above wins and gets an entry in the projects Hall of Fame.
EDIT: Hint
Upon submission of Chris Goldsby's 99% solution, he received the following hint:
The syntax highlighting of
protocol P {
typealias P
var p : P { get }
}