Timeline for Minimizing string length checker in C# + format(ish) function
Current License: CC BY-SA 4.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 31, 2020 at 1:04 | comment | added | TessellatingHeckler |
@Brian yeah there's not much in it - the single line answer is deceptive, as it still depends on doing a Split() and then assigning three parts of the array to three new string variables, so it ends up longer and less obviously correct from that. And if you inline the checks to parts[1].Length == 3 && then the added bracket indexing in one line starts to get a bit dense for my liking. It's A && B || C && !D style code which makes me unhappy - so hard to verify by eye that the tests do exactly what was intended in every case, but == && == && == could be simple enough.
|
|
Jan 30, 2020 at 14:10 | comment | added | Brian | In the general case, the, "escape out quickly on any failure" approach is great. In the OP's specific code, using a single return statement is both simpler and more readable. | |
Jan 30, 2020 at 12:18 | history | edited | TessellatingHeckler | CC BY-SA 4.0 |
added 4 characters in body
|
Jan 30, 2020 at 12:11 | history | answered | TessellatingHeckler | CC BY-SA 4.0 |