Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Arbitrary nesting of expressions without expansion of escape sequences is available in many other languages that employ a string interpolation method that uses expressions instead of just variable names. Some examples:

  # Ruby
  "#{ "#{1+2}" }"

  # JavaScript
  `${`${1+2}`}`

  # Swift
  "\("\(1+2)")"

  # C#
  $"{$"{1+2}"}"
To which I might add

  # Perfect
  "\{"\{1+2}"}"
basically Swift but { instead of ( as { is 'more decorative' so a better indicator that something special is going on. \ is already the escape character for such thing as \n and friends, so no extra escaping needed for e.g. ${


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: