Zack Lee
Zack Lee

Reputation: 3044

NewLine(\n) alternative in Lua?

I'm looking for an alternative way to express new line(\n) in Lua since my host application doesn't allow users to use \ character.

Here's my code:

local str = "Hello\nWorld"
print(str)

Is there any alternative solution to make the same string without using \n character?

Upvotes: 6

Views: 36860

Answers (1)

lhf
lhf

Reputation: 72312

You can enter newlines directly into the string using long strings:

local str = [[Hello
World]]

Upvotes: 8

Related Questions