© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
__dil__

❔ Is there a built-in way to map (transform) a tuple?

For example, I'd like to do this (hypothetical code):
bool foo = (val: 1.0, truthiness: true, name: "hello").Map((bar) => { bar.val > 0 && bar.name == "Bob" || bar.truthiness });
bool foo = (val: 1.0, truthiness: true, name: "hello").Map((bar) => { bar.val > 0 && bar.name == "Bob" || bar.truthiness });

instead of that
var bar = (val: 1.0, truthiness: true, name: "hello");
bool foo = bar.val > 0 && bar.name == "Bob" || bar.truthiness;
var bar = (val: 1.0, truthiness: true, name: "hello");
bool foo = bar.val > 0 && bar.name == "Bob" || bar.truthiness;


The reasoning is that it's cumbersome to have to introduce variable names for intermediate computations involving tuples. Being able to transform them directly makes it possible to avoid that.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Is there a faster way to map endpoints?
C#CC# / help
7mo ago
A built in way to send SIGTERM ?
C#CC# / help
16mo ago
❔ Is there a way to override the DefaultInterpolatedStringHandler?
C#CC# / help
3y ago