It's a rather interesting feature. I first use it the same way as the python tuple type. I immediately found I was wrong.
It doesn't support using an index to visit certain element
Stupid enough. I think. Soon I found the correct way, you know, the Item1, Item2 way.
It's so Stupid! Then I found the best way: the named element way.
Task<(List<string> orderIdList, List<string> orderNoList)> GetExpiringOrderIdListAndOrderNoList(DateTime checkTime);
Ok. It's not very stupid.
I had written the following code in a project
...
return s && s.value || null
It works well for some days until a colleague did some code refactoring. In the beginning, s.value is a string value, and an empty string is not a valid value, so the code works well. After the refactoring, s.value became an integer, and this time 0
is a valid value. So you can imagine when s.value === 0
the code above will return null instead of 0. It leads to a bug!
Therefore please use the"A || B
" expression with caution!
Two articles explain well this subject. One is in Chinese, the other is in English.