|
|
@ -2,8 +2,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
### Instructions |
|
|
|
### Instructions |
|
|
|
|
|
|
|
|
|
|
|
- Write a function that takes a slice of integers and int and adds integer in the slice then returns the slice |
|
|
|
Write a function that takes a slice of integers and an `int` as arguments, adds the `int` to the slice and returns it. |
|
|
|
- If the slice is empty, return a slice with the new value |
|
|
|
- If the slice is empty, return a slice with the new value. |
|
|
|
|
|
|
|
|
|
|
|
### Expected function |
|
|
|
### Expected function |
|
|
|
|
|
|
|
|
|
|
@ -22,11 +22,13 @@ package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"piscine" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
fmt.Println(SliceAdd([]int{1, 2, 3}, 4)) |
|
|
|
fmt.Println(piscine.SliceAdd([]int{1, 2, 3}, 4)) |
|
|
|
fmt.Println(SliceAdd([]int{}, 4)) |
|
|
|
fmt.Println(piscine.SliceAdd([]int{}, 4)) |
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|