• @Gecko
    link
    English
    172 years ago

    Type error unless there’s an implementation of + that specifies adding together and integer and a string.

    • @[email protected]
      link
      fedilink
      English
      102 years ago

      💯% accurate. funny how the typescript developer thinks this is some kind of “gotcha!”… like maybe just try a language besides typescript and find out for yourself 😆

    • @[email protected]
      link
      fedilink
      English
      02 years ago

      Exactly. Most languages I know of that allow this at all will coerce the “1” to an integer and give x = 2. They get away with this because they define the “+” operator as taking numbers only as arguments, so if you hand them x = x + "cheese" they’ll error out.