100-go-mistakes/3-data-types/23-checking-slice-empty/main.go
2021-12-27 15:56:17 +01:00

29 lines
464 B
Go

package main
func handleOperations1(id string) {
operations := getOperations(id)
if operations != nil {
handle(operations)
}
}
func handleOperations2(id string) {
operations := getOperations(id)
if len(operations) != 0 {
handle(operations)
}
}
func getOperations(id string) []float32 {
operations := make([]float32, 0)
if id == "" {
return operations
}
// Add elements to operations
return operations
}
func handle(operations []float32) {}