underscore/docs/content/collections/map.md
Ruidy d19fa7b8c9
docsite (#19)
* change documentation theme and structure

* add config files

* fix links

* add build doc command

Co-authored-by: Ruidy <rnemausat@newstore.com>
2022-03-23 10:32:56 -04:00

372 B

title date
Map 2022-03-21T13:32:10-04:00

Map produces a new slice of values by mapping each value in the slice through a transform function.

package main

import (
	"fmt"
	u "github.com/rjNemo/underscore"
)

func main() {
	nums := []int{1, 2, 3}
	toSquare := func(n int) int {
		return n * n
	}
	fmt.Println(u.Map(nums, toSquare)) // {1, 4, 9}
}