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

FirstOrFallback and LastOrFallback #67

Open
GoogleCodeExporter opened this issue Oct 27, 2015 · 1 comment
Open

FirstOrFallback and LastOrFallback #67

GoogleCodeExporter opened this issue Oct 27, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Just ran into a situation where FirstOrFallback would have been nice to have. I 
have a list of ranges specified by an editor of the website. The user enters a 
number on the site and I need to find the correct range. I have no control over 
the editor and the way he defines the ranges so there is a possiblity that 
ranges overlap or that the number entered by the user falls outside the ranges. 
So something like this would do it:

var rangeWithLargestCeiling = ranges.MaxBy(x=>x.Ceiling).Single();

var range = ranges
    .Where(x => IsInRange(number,x))
    .FirstOrFallback(() => rangeWithLargestCeiling);

This will handle both the overlapping issue (where there is more than one range 
where the number is in range) and the fallback.

Original issue reported on code.google.com by hammerskov on 7 Jun 2011 at 7:05

@GoogleCodeExporter
Copy link
Author

This issue has been migrated to:
https://github.com/MoreLINQ/morelinq/issues/67
The conversation continues there.
DO NOT post any further comments to the issue tracker on Google Code as it is 
shutting down.
You can also just subscribe to the issue on GitHub to receive notifications of 
any further development.

Original comment by azizatif on 21 Aug 2015 at 6:55

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

No branches or pull requests

1 participant