• Gsus4@mander.xyz
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    4 days 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 🤭

    • dalekcaan@lemm.ee
      link
      fedilink
      arrow-up
      1
      ·
      3 days ago

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

      • Gsus4@mander.xyz
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        4 days 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 😇

        • palordrolap@fedia.io
          link
          fedilink
          arrow-up
          0
          ·
          4 days ago

          it commutes

          Maybe the behaviour with regard to type conversion, but not for the operation itself.

          “13”+12 and 12+“13” don’t yield the same result.