Comment

Comment by kcartlidge

I much prefer C# 11's raw string literals. It takes the indentation of the first line and assumes the subsequent ones have the same indentation.

  string json = $"""
      <h1>{title}</h1>
      <article>
          Welcome to {sitename}.
      </article>
      """;
And it even allows for using embedded curly braces as real characters:

  string json = $$"""
      <h1>{{title}}</h1>
      <article>
          Welcome to {{sitename}}, which uses the <code>{sitename}</code> syntax.
      </article>
      """;
The $ (meaning to interpolate curly braces) appears twice, which switches interpolation to two curly braces, leaving the single ones untouched.
parent kcartlidge 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton