C#C
C#3y ago
__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 });

instead of that
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.
Was this page helpful?