Help us shape the future of Go! Take the 2026 Go Developer Survey

flatten

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2019 License: MIT Imports: 1 Imported by: 0

README

Flatten

Flattens an arbitrarily nested array of Type into a flat array of Type, e.g. [[1,2,[3]],4] -> [1,2,3,4].

Currently only the int type is supported via the flatten.Int function. Additional types may be supported in the future.

Example Usage

func Int([]interface{}) ([]int, error)

input := []interface{}{
  []interface{}{
    1,
    2,
    []interface{}{
      3,
    },
  },
  4,
}

ints := flatten.Int(input)
fmt.Println(ints) // [1 2 3 4]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int

func Int(input []interface{}) ([]int, error)

Int flattens an arbitrarily nested array of integers into a flat array of integers.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL