Last active
August 29, 2015 14:02
-
-
Save drumnkyle/1ed7ac767e9f9a50d2f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The difference between declaring a method in a class, a function | |
// outside of a class, and an init method. | |
func foo(#a: String, #b:String) -> String { | |
return a + " " + b | |
} | |
foo(a:"Hello", b:"dude") | |
func foo1(a: String, b: String) -> String { | |
return a + " " + b | |
} | |
foo1("Hello", "dude1") | |
class FooClass { | |
let one, two : String | |
init(one: String, two: String) { | |
self.one = one | |
self.two = two | |
} | |
init(one: String, and two: String) { | |
self.one = one | |
self.two = two | |
} | |
func foo(#a: String, b: String) -> String { | |
return a + " " + b | |
} | |
func foo1(a: String, b: String) -> String { | |
return a + " " + b | |
} | |
func foo2(a: String, _ b: String) -> String { | |
return a + " " + b | |
} | |
func description() -> String { | |
return one + " " + two | |
} | |
} | |
var fooObj = FooClass(one: "Yo", two: "world") | |
fooObj.foo(a: "Hello", b: "world") | |
fooObj.foo1("Test", b: "man") | |
fooObj.foo2("I", "am") | |
fooObj.description() | |
var fooObj1 = FooClass(one: "Wow", and: "cool") | |
fooObj1.description() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment