Skip to content

feat: supporting reduce with no initializer#70

Merged
Farenheith merged 1 commit intomasterfrom
reduce-no-initializer
Dec 9, 2023
Merged

feat: supporting reduce with no initializer#70
Farenheith merged 1 commit intomasterfrom
reduce-no-initializer

Conversation

@Farenheith
Copy link
Copy Markdown
Member

Arrays support calling reduce with no initializer, which makes the first call have the first and second elements and the subsequent calls behave as any other reduction call. This reduce implementation makes fluent to behave just like that, but with a stronger type definition.

This type of call is ideal to be used when the result has the same type of elements. If you want to change the result type, you can explicitly inform it through generics, but be aware: if the array has only one element, the result will still have the same type of elements, as the callback won't be called. For this reason, the result type in this case is ambiguous, and is up to the lib user to guarantee its consistency

Arrays support calling reduce with no initializer, which makes the first call having the first and
second elements, and the subsequent calls to behave as any other reduction call.
This implementation makes reduce on fluent to do behave just like that, but with a stronger
type definition.

This type of call is ideal to be used when the result have the same type of the elements.
If you want to change the result type, you can excplicitly inform it through generics, but be aware:
if the array have only one element, the result will still have the same type of the elements,
as the callback won't be called. For this reason, the result type in this case is ambiguous, and
is up to the lib user to guarantee its consistency
@Farenheith Farenheith force-pushed the reduce-no-initializer branch from c9b7077 to 0785dee Compare December 9, 2023 14:15
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Dec 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Farenheith Farenheith merged commit da912a9 into master Dec 9, 2023
codibrebot pushed a commit that referenced this pull request Dec 9, 2023
# [1.36.0](v1.35.0...v1.36.0) (2023-12-09)

### Features

* supporting reduce with no initializer ([#70](#70)) ([da912a9](da912a9))
@codibrebot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.36.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants