We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Suppose there are two arrays, aa and bb. I want to convert them into a map in the form of {a: b}. Currently, I need to write the code like this:
aa
bb
{a: b}
aToB := lo.FromEntries(lo.Map(lo.Zip2(aa, bb), func(kv lo.Tuple2[int64, string], _ int) lo.Entry[int64, string] { return lo.Entry[int64, string]{ Key: kv.A, Value: kv.B, } }))
It would be much more convenient if there were a method that could directly convert lo.Tuple2 to lo.Entry.
lo.Tuple2
lo.Entry
The text was updated successfully, but these errors were encountered:
First, i wonder if lo.Entry struct is still useful, since we now have lo.Tuple2.
As a soft breaking change, we could imagine the following helpers:
With such helpers, your example would be simply:
aToB := lo.FromPairs(lo.Zip2(aa, bb))
Until then, you can do something like:
lo.SliceToMap(lo.Zip2(aa, bb), func(t lo.Tuple2[K, V]) (K, V) { return t.A, t.B })
[edit]: Sorry, lo.FromPairs and lo.ToPairs helpers already exist
lo.FromPairs
lo.ToPairs
Sorry, something went wrong.
It's great to replace lo.Entry with lo.Tuple2. They are kind of repetitive.
No branches or pull requests
Suppose there are two arrays,
aa
andbb
. I want to convert them into a map in the form of{a: b}
. Currently, I need to write the code like this:It would be much more convenient if there were a method that could directly convert
lo.Tuple2
tolo.Entry
.The text was updated successfully, but these errors were encountered: