The closure you are assigning to foo is independent of your LMAO class so it has no "self".
if you want to initialize your foo variable with code from the current instance's self, you need to use lazy initialization. You will also need to link to the current instance somehow (a plain closure will not do it ).
the easiest way would probably be to add a defaultFoo function to your class and assign it as the initial value:
class LMAO: LOL
{
lazy var foo: ((String) -> Bool)? = self.defaultFoo
func defaultFoo (_ lol: String) -> Bool
{
self.rofl()
return true
}
func rofl() {}
}
At this point you probably don't need foo to be an optional, but that's up to you.