avli
avli

Reputation: 1151

How can I do a line break (line continuation) in Elixir?

In Python, for example, one can break line with '\' character (yeah, necessary evil). Is it possible to break lines in Elixir?

Upvotes: 20

Views: 11232

Answers (2)

elpddev
elpddev

Reputation: 4484

Based on Jose Valim comment.

iex(1)> "hello\
...(1)> world"
"helloworld"
iex(2)> 

Upvotes: 9

whatyouhide
whatyouhide

Reputation: 16781

Elixir is not as whitespace-sensitive as Python, so you can do things like:

a =
  2 + 4 +
 3
# a is bound to 9

If you want to break strings, probably your best shot is to concatenate one string per line:

"this is a very long string that " <>
  "spans multiple lines because man, " <>
  "is it long"

Upvotes: 24

Related Questions