Re:Tuples goodness in .NET 4.7.1
by redmand on Monday March 12, 2018 @12:32PM
(#16569277)
I'll use them for data passing within a class. The calling method needs multiple values of differing types and I can't personally justify creating a class just to encapsulate those values for a call or two. So I tuple. But that tuple stays within that class and is never exposed or stored.
[ Parent
| on HN ]
Re:Tuples goodness in .NET 4.7.1
by arwhatever on Monday March 12, 2018 @12:57PM
(#16569501)
Good call on the encapsulation. I've encountered the occasional public API with methods that require some type like a Tuple<int, int, string>, and got pretty peeved. And go ahead and name the argument "values" or something similar, for good measure.
The new tuples do allow names, which can be a nice half way house so you can do something like
(bool success, string errormessage, foo addedItem)
as a return type. A big step up from Tuple<bool, string, foo>!