Zorgatone
10/26/2015 - 7:58 AM

Swift 2.1 Hello World test

Swift 2.1 Hello World test

//
//  swift-test-hello.swift
//  Swift 2.1 tests
//

//import Foundation

class Person {
    var name: String;
    var surname: String?;
    
    init(name: String, surname: String? = nil) {
        self.name = name
        self.surname = surname
    }
    
    func fullname() -> String {
        if let s = surname {
            return "\(name) \(s)"
        } else {
            return "\(name)"
        }
    }
}

func greeting(person: Person? = nil) {
    if let p = person {
        print("Hello, \(p.fullname())!")
    } else {
        print("Hello, World!")
    }
}

let john = Person(name: "John")

//greeting()
greeting(john)