github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/internal/examples/loopexamples/loop_Flat_test.go (about)

     1  package loopexamples
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/m4gshm/gollections/convert/as"
     9  	"github.com/m4gshm/gollections/loop"
    10  )
    11  
    12  func Test_Flat(t *testing.T) {
    13  
    14  	var i []int = loop.Flat(loop.Of([][]int{{1, 2, 3}, {4}, {5, 6}}...), as.Is).Slice()
    15  	//[]int{1, 2, 3, 4, 5, 6}
    16  
    17  	assert.Equal(t, []int{1, 2, 3, 4, 5, 6}, i)
    18  }