News for hackers. Stuff that matters.
Re:Nil in Go is typed in theory and sort of untyped in practice by camjw on Wednesday March 31, 2021 @04:02PM (#26652354)
I think the classic example is [] == ![] evaluates to true. It’s not absurd logically, just the operators act weirdly/non-standardly.
Re:Nil in Go is typed in theory and sort of untyped in practice by qsort on Wednesday March 31, 2021 @04:31PM (#26652745)
Honestly that's more of a weirness of the '==' operator, which is kind of deprecated in modern JS. On the other hand I fully agree that non-strict definitions of equality are bound to generate weird cases around nullish values.
Re:Nil in Go is typed in theory and sort of untyped in practice by mirekrusin on Wednesday March 31, 2021 @04:28PM (#26652707)
Yeah, that one is funny

  > [] == []
  false
  > [] == ![]
  true
Re:Nil in Go is typed in theory and sort of untyped in practice by mirekrusin on Wednesday March 31, 2021 @04:31PM (#26652746)
However typescript says:

  This condition will always return 'false' since the types 'never[]' and 'boolean' have no overlap.
...for `[] == ![]`. Which is ironic because it does return true, not false. However at least it flags an error!

I wonder how much of weirdness is wiped out by linters/ts/etc.