Skip to content

Instantly share code, notes, and snippets.

@domarps
Created March 17, 2020 15:22
Show Gist options
  • Save domarps/ba1aca467c9b0bd80506f10c7cd9c6f4 to your computer and use it in GitHub Desktop.
Save domarps/ba1aca467c9b0bd80506f10c7cd9c6f4 to your computer and use it in GitHub Desktop.
print("Hello World!")
let airports: [String : String] = [
"SFO" : "San Francisco",
"BOS" : "Boston"
]
for (code, name) in airports {
print("\(code) : \(name)")
}
func sayHello(name: String, msg : String) -> String {
let message = "Hello \(name)"
print(message)
return message
}
sayHello(name : "Pramod", msg : "Stay Safe")
struct Course {
let name : String
let instructor : String
}
class Person {
var name : String
init(name : String) {
self.name = name
}
func sayHello()
{
print("I'm \(name)")
}
}
let person1 = Person(name : "Tommy")
person1.sayHello()
class Vehicle
{
func wheels() -> Int {
return 4
}
func go()
{
print("Zoom")
}
}
class MotorCycle : Vehicle
{
override func wheels() -> Int {
return 2
}
}
protocol Teacher {
func teach();
}
var name: String?
if let n = name {
print(n)
}
else
{
print("No name")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment