![]() ![]() However, unlike a string literal, the content of a text block is processed by the Java compiler in three distinct steps: JEP 355: Text Blocks (Preview)Ī text block is a constant expression of type String, just like a string literal. There is a concept of incidental white space. What is the purpose of stripIntent for text block? I know it is easy to understand when use it on a normal string. Updated: After read the related java doc, I think after the text block is compiled, it should has stripped the left intents of the lines in the block. The whitespaces before every lines are NOT removed by stripIntent as expected. Update: Just print hello2 stripIntent, ("hello2 after stripIntent():\n" hello2.stripIndent()) I am not sure where is wrong, or this is a text block design purpose? Hello is equals hello2 after stripIndent():false ![]() The output console is like: hello is equals hello2:false ("hello is equals hello2 after stripIndent():" hello.stripIndent().equals(hello2.stripIndent())) ("hello is equals hello2:" hello.equals(hello2)) To align with the the closing delimiter ("""), the multiline string left spaces before every lines.īut when I tried to compare the following two text block string, they are same format in the output console, but they are not equals, even after stripIntent. ("SQL or JPL like query string :\n" query) The closing triple quotation marks will affect the format. I just tried the new text block feature in Java 13 and encountered a small issue.
0 Comments
Leave a Reply. |