logoalt Hacker News

IshKebab08/10/20252 repliesview on HN

For those of us that haven't used Java for a decade...

> In text blocks, the leftmost non-whitespace character on any of the lines or the leftmost closing delimiter defines where meaningful white space begins.

From https://blogs.oracle.com/javamagazine/post/text-blocks-come-...

It's not a bad option but it does mean you can't have text where every line is indented. This isn't uncommon - e.g. think about code generation of a function body.


Replies

gf000last Monday at 4:17 AM

Why couldn't you have it?

You just put the ending """ where you want it relative to the content.

show 1 reply
Tweylast Monday at 1:41 AM

Right, this is a pretty common syntax, but doesn't address the same problem as Zig's syntax.

I've only seen two that do: the Zig approach, and a postprocessing ‘dedent’ step.