• Gsus4@mander.xyz
    link
    fedilink
    arrow-up
    98
    ·
    8 months ago

    Hm, playing devil’s advocate, I think it is because the minus has not been defined as a string operation (e.g. it could pop the last char), so it defaults to the mathematical operation and converts both inputs into ints.

    The first is assumed to be a concat because one of the parcels is a string…

    It’s just doing a lot of stuff for you that it shouldn’t be in first place 🤭

      • Gsus4@mander.xyz
        link
        fedilink
        arrow-up
        18
        ·
        edit-2
        8 months ago

        Yeah, I actually had to try 1+“11” to check that it didn’t give me 12, but thankfully it commutes it’s consistent 😇

    • dalekcaan@lemm.ee
      link
      fedilink
      arrow-up
      13
      arrow-down
      1
      ·
      8 months ago

      Yeah, this looks dumb on the surface, but you’ve got bigger problems if you’re trying to do math with strings