|
|
|
|
|
by crubier
1106 days ago
|
|
All of these could be equally valid results of your list comparison: True, False, [True, False], [[True, True], [True, False]]. I like that typescript does not rely on an implicit choice, but let’s me express exactly what comparison I care about. |
|
This has been a suprising thread to me -- I just assumed "everyone knew" that the vast majority of languages do lexicographic comparision of lists.
I will say typescript does "rely on an implicit choice", it has a default implement (the "convert to string"), which I'm going to be honest, doesn't ever seem like a sensible choice to me -- although maybe it feels more natural to javascript/typescript people.
My personal upset (I lost like a day to this) is that if you keep your numbers under 10, you do get the lexicographic ordering, as then lexicographic = string. I had a bunch of unit tests (all using numbers under 10), just larger inputs kept breaking, and it didn't occur to me to go read the docs for < :)