Swift: A struct with a closure

When Swift was introduced last year by Apple in one of its events, it mentioned about closure, and I have no idea what that was.  I have looked at Swift for a couple of days and I am still a bit confused about how it is going to be used.

Closure is a piece of very concise code and it is actually quite easy to construct as shown in this example.

struct Square{
    var width = 0
    var height = 0
    func area()->Int{
        return width*height
    func printArea(){
        print("area \(area())")
    func repeatTill(count count:Int , _ delimiter:String) {
        for _ in 1...count {

var square = Square(width: 10, height: 5)



Series Navigation<< Swift: Simple inheritance with a method
Swift: Else if >>