question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add deconstruct to Option/Maybe to support eg (hasValue, value) = collection.TryFirst(...)

See original GitHub issue

Based on a suggestion from @pkanavos:

  1. Add a deconstruct to Option<T> (and Maybe<T> if it doesn’t just work through implicit casting):
public void Deconstruct<T>(out bool hasValue, out T value) => ...
  1. Look at possibly adding similar deconstructs to Success<T>, Either<T1, T2> and union types.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
megafinzcommented, Jun 30, 2017

Option<T>.ValueOrDefault seems legit.

0reactions
DavidArnocommented, Feb 13, 2018

Added to v3.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to null check c# 7 tuple in LINQ query?
The method is called FirstOrDefault , not TryFirst . It's not meant to check whether a value exists or not, although we all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found