2016-02-18 Swift error Instance member cannot be used on type

Today, Swift gave me the error:

  Instance member "membername" cannot be used on type "Classname"

The code was as follows:

  public class SomeClass {
      public let defaultGreeting = "Hello, playground"
      public var greeting = defaultGreeting
  }

The solution is as follows:

  public class SomeClass {
      public let defaultGreeting = "Hello, playground"
      public var greeting: String!
  
      init() {
          self.greeting = defaultGreeting
      }
  }

The reason you're getting the error, is because the class member defaultGreeting is declared but not yet initialized at the class scope. However, when you hit init() then it's available.