Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Initializer Swift

// declare a class
class  Wall {
  var length: Double

  // initializer to initialize property
  init() {
    length = 5.5
    print("Creating a wall.")
    print("Length = ", length)
  }
}

// create an object
var wall1 = Wall()
 
PREVIOUS NEXT
Tagged: #Initializer #Swift
ADD COMMENT
Topic
Name
2+7 =