6

`heyy ${uu}`
'heyy '+uu
"Heyy "+uu

Which one do you use¿ And wheres poll bot :'

Comments
  • 9
    "hey" << uu

    Depends a lot on the language.
  • 6
    First :) Might use second with spaces around the plus sign. Basically never use double quotes. Assuming you mean JS, that is.
  • 7
    Js: first
    Most other languages: "hey"+uu

    I have this problem of strings being in double quotes, and chars (single letters) being in single quotes 🤷‍♂️
  • 1
    First, but interestingly enough, the second is still in my muscle memory.

    Third only when I'm drunk or doing golang.
  • 3
    @green-portal bring out the pitchforks ;)
  • 3
    In JS I exclusively use template strings, I even have an eslint rule against adding something to a string literal
  • 1
    $"Heyy {uu}";
  • 3
    @C0D4 I /C/ where you are coming from
  • 1
    Assuming JS/TS related..?

    I use the first option if I need to reference any variables in building the string, purely because it's easier to read. (This also makes it easier to bounce between TS and Flutter, which I do quite often)

    Otherwise I use the third option, because then I don't need to escape any apostrophes that the string might contain.

    For the most part, I find strings tend to contain apostrophes way more often than quotation marks..
  • 1
    First.

    Anything without interpolation is in single quotes. (Except in C, ofc)
Add Comment