Created
June 20, 2019 20:09
-
-
Save mottet-dev/30afa016cdd0344fde49801747c9a52f to your computer and use it in GitHub Desktop.
Go Funk - Map - Type assertion
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
package main | |
import ( | |
"fmt" | |
"github.com/thoas/go-funk" | |
) | |
func main() { | |
baseSlice := []int{1, 2, 3, 4, 5} | |
newSlice := funk.Map(baseSlice, func(x int) int { | |
return x + 1 | |
}).([]int) | |
fmt.Println(baseSlice) | |
fmt.Println(newSlice) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment