• sus
    link
    fedilink
    arrow-up
    65
    ·
    edit-2
    4 months ago

    but sometimes “👍🏽”.reverse() == “🏽👍”

  • SzethFriendOfNimi@lemmy.world
    link
    fedilink
    arrow-up
    58
    ·
    4 months ago

    Imagine, if you will. A world where string reverse changes the character codes of the string.

    What beauty, what wonder would such a world have?

    Destruction and despair. Developers unsure why their programs don’t respond correctly. Ships run aground on islands already overcrowded with those who were shipwrecked before. Signal antennas pointed towards the sun with it’s constant noise. Spacecraft whose exhaust melt to slag populated cities as people briefly scream their final terrors of pain and suffering.

    This, is a world we should not want to live in. A world you can only find, in the Twilight Zone.

    • lad
      link
      fedilink
      English
      arrow-up
      5
      ·
      4 months ago

      Nah, this could’ve been possible with some clever fuckery in defining those emojis’ unicode content, like with flags that are not a single point but three independent ones, allowing you to do this:

      "🇧🇬".reverse() == "🇬🇧"
      "🇬🇪".reverse() == "🇪🇬"
      
    • hydroptic@sopuli.xyzOP
      link
      fedilink
      arrow-up
      45
      ·
      4 months ago

      Use a dynamically typed language and you won’t have to: just override the default reverse() method on strings like a Real Programmer!

      Unintended consequences you say? Nonsense! What could possibly go wrong?

      • petey@aussie.zone
        link
        fedilink
        arrow-up
        27
        ·
        4 months ago

        I’m tempted to publish an NPM package to do so as a joke, but I fear that it’d get used seriously

        • RonSijm
          link
          fedilink
          arrow-up
          7
          ·
          4 months ago

          Where does it end though? It’s a bit like infinite craft - but instead of combining resources you’d have to find an inverse for every emoji

          • Feathercrown@lemmy.world
            link
            fedilink
            English
            arrow-up
            6
            ·
            edit-2
            4 months ago
            async function reverse(str){
                return ChatGPT.ask(`Please reverse the string ${str}. Reply only with the answer, without other words or symbols.`);
            }
            
  • lad
    link
    fedilink
    English
    arrow-up
    11
    ·
    4 months ago

    Yet we live in a world where

    "🇧🇬".reverse() == "🇬🇧" and "🇬🇪".reverse() == "🇪🇬"

  • MrLLM@ani.social
    link
    fedilink
    English
    arrow-up
    7
    ·
    4 months ago
    File "<stdin>", line 1
        "👉".reverse() = "👈"
        ^
    SyntaxError: cannot assign to function call
    
    • derpgon
      link
      fedilink
      arrow-up
      15
      ·
      4 months ago

      It is a font that changes == to one long equals sign.

      • MrLLM@ani.social
        link
        fedilink
        English
        arrow-up
        4
        ·
        4 months ago

        Oh my bad, that idea didn’t cross my mind.

        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        AttributeError: 'str' object has no attribute 'reverse'
        
    • hydroptic@sopuli.xyzOP
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      edit-2
      4 months ago

      That’s known as a ligature and they’re pretty common in many programming-oriented fonts, which usually have stylistic sets with different ligatures for different programming languages that you can optionally enable in your editor’s configuration. For example, here’s the stylistic sets the Monaspace font offers:

      Personally I’m not too fond of ligatures so I never enable any, but many folks do like them.

      Edit: and just as a side note, ligatures are super common in many fonts, you just might not notice them. Here’s some classic examples from the DejaVu Serif font, with and without a ligature: