Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to obtain a map as an output of stream operations? #2

Closed
seanrmurphy opened this issue Aug 5, 2020 · 1 comment
Closed

Comments

@seanrmurphy
Copy link

Is seems straightforward to obain an array as an output of stream operations (using ToArray()). Is it also possible to obtain a map?

@jucardi
Copy link
Owner

jucardi commented Oct 17, 2020

@seanrmurphy sorry for the late response, right now you can't obtain a map, you can however obtain a KeyValuePair list which you could convert into a map

source := map[string]string{
// . . .  Some data here in the map
}

target := map[string]string{}

streams.From(b). {some operations here} .ForEach(func (i interface{} {
    x := i.(streams.KeyValuePair)
    target[x.Key.(string)] = x.Value(string)
})

@jucardi jucardi closed this as completed Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants