
Creating a function
To create a basic function:
Then you call it with:
This would print a message “Just created my first function!” in the console. To create a function with parameters:
This function will take 2 parameters – ‘a’ and ‘b’ and then return the Sum of both as an Integer value. The way […]
1 2 3 4 5 |
func myFunction() { println("Just created my first function!") } |
1 |
myFunction() |
1 2 3 4 5 |
func add(a: Int, b: Int)-> Int { return a + b } |