8000 added method `Flat` by misikdmytro · Pull Request #187 · elliotchance/pie · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

added method Flat #187

Merged
merged 3 commits into from
Feb 17, 2023
Merged

added method Flat #187

merged 3 commits into from
Feb 17, 2023

Conversation

misikdmytro
Copy link
Contributor

No description provided.

@misikdmytro misikdmytro changed the title added methods Flat & FlatMap added methods Flat & FlatMap Feb 10, 2023
@misikdmytro misikdmytro changed the title added methods Flat & FlatMap added methods Flat & FlatMap Feb 10, 2023
v2/of.go Outdated
@@ -57,6 +57,10 @@ func (o OfSlice[T]) FirstOr(defaultValue T) T {
return FirstOr(o.Result, defaultValue)
}

func (o OfSlice[T]) FlatMap(fn func(T) []T) OfSlice[T] {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Flat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flat works with a 2-dimensional array, I'm not sure it should be part of the OfSlice type

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be part of OfSlice since it deals with slices.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's impossible to add Flat to the OfSlice type because Result is a one-dimensional slice ([]T) but Flat works with a two-dimensional slice ([][]T) so this does not work:

func (o OfSlice[T]) Flat() []T {
	return OfSlice[T]{Flat(o.Result)}
}

if you mean another way to add it to the OfSlice type I'll be thankful for your help

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you mean. That's fair - you can leave it out.

@misikdmytro misikdmytro changed the title added methods Flat & FlatMap added method Flat Feb 16, 2023
v2/of.go Outdated
@@ -57,6 +57,10 @@ func (o OfSlice[T]) FirstOr(defaultValue T) T {
return FirstOr(o.Result, defaultValue)
}

func (o OfSlice[T]) FlatMap(fn func(T) []T) OfSlice[T] {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be part of OfSlice since it deals with slices.

@elliotchance elliotchance merged commit 4abd3ae into elliotchance:master Feb 17, 2023
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

Successfully merging this pull request may close these issues.

2 participants
0