Support functions with parameters

This commit is contained in:
Ayke van Laethem
2018-04-13 02:11:12 +02:00
parent e0da91f753
commit 6a8dc7ca9a
2 changed files with 86 additions and 17 deletions
+10
View File
@@ -6,9 +6,19 @@ const SIX = 6
func main() {
println("Hello world from Go!")
println("The answer is:", calculateAnswer())
println("5 ** 2 =", square(5))
println("3 + 12 =", add(3, 12))
}
func calculateAnswer() int {
seven := 7
return SIX * seven
}
func square(n int) int {
return n * n
}
func add(a, b int) int {
return a + b
}