In The Newspaper

discarded stories

I wonder, if I draw a line...

Discards are not complex construct but there's still one interesting use-case worth mentioning.

We can use discard when we use an operator that needs a left-hand side value but we actually do not care about. One of such operator is ?? - null-coalescing. To use it we need something on the left side as we can't just write

valueToProcess ?? throw new ArgumentNullException(nameof(valueToProcess));

but we can write

_ = valueToProcess ?? throw new ArgumentNullException(nameof(valueToProcess));

One just need to remember that _ is still a valid identifier in some context so it might produce unexpected results if one is not careful enough.

Docs 📑: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/discards#a-standalone-discard

#dotnet #deconstruct #discards
---
If you find this useful, consider giving a like & share ♻

Discards - unassigned discardable variables - C#

Describes C#'s support for discards, which are unassigned, discardable variables, and the ways in which discards can be used.

Talking about deconstructing, it's not possible to not mention discards.

Deconstructing an object is nice, but sometimes we only care about certain values from the deconstructed object. We could, of course, declare extra variables and just not use them, but why the extra need for dealing with one of the most difficult things in IT - naming things - if we can live without that?

Discards come into play here (not only here). We could use a discard character, such as an underscore (_), for some of the variable names in the deconstruction. This will tell the compiler that we do not care about the variable and we don't need it. The compiler will take care of extracting only the values we need, and we end up with code that's not polluted by unnecessary variables. Nice and simple.

Docs 📑: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/discards

#dotnet #deconstruct #discards
---
If you find this useful, consider giving a like & share ♻

Discards - unassigned discardable variables - C#

Describes C#'s support for discards, which are unassigned, discardable variables, and the ways in which discards can be used.

Does #fish that is returned to #sea after catching stand a chance if survival? This video shows how we carry out survival research of these so-called #discards in #fisheries. 👇

The video only shows the method and doesn't show results. The research shows that survival chances depend on fish species, gear type, water temperature and weather.

#science #fisheriesscience #marinescience

https://m.youtube.com/watch?v=oezM7py0UZM&list=PLuJyz0gvHVHs9eLtcJ7sAlK3x6z-YBgTk&index=33&pp=iAQB

Fish survival: method and results

YouTube

Presents are unwrapped
Tree is untrimmed, what now?
The afterlife awaits

#afterlife #holiday #discards #haiku #poetry

https://www.nytimes.com/2022/12/27/opinion/holiday-discards.html

Opinion | The Afterlife of Your Holiday Discards

The cartoonist Amy Hwang explores what happens after the presents are unwrapped and the tree is untrimmed.