# Line breaks in Julia

**URL:** <https://discourse.julialang.org/t/line-breaks-in-julia/70037>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 19, 2021, 2:45pm UTC](https://discourse.julialang.org/t/line-breaks-in-julia/70037 "2021-10-19T14:45:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [October 19, 2021, 2:45pm UTC](https://discourse.julialang.org/t/line-breaks-in-julia/70037/1 "2021-10-19T14:45:55Z")

</div>

So most of the time, I do not need to worry about line breaks like in Matlab (`...`)?

Below is an example of a Julia code that can extend to many lines (I have many A, B, C,… and each of them are very long):

```julia
IndexT2 = map(A, B, C, D, E) do a, b, c, d, e
(a >= -20) && (b >= 15) && (c > 0) && (d == 2) && (e >= 500);
end

```

Unfortunately, if I break it like the below, Julia will report errors and refuse to execute:

```julia
IndexT2 = map(A, B, C, D, E) 
do a, b, c, d, e
(a >= -20) && (b >= 15) && (c > 0) && (d == 2) && (e >= 500);
end

```

In this case, does Julia want a line break?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 19, 2021, 2:48pm UTC](https://discourse.julialang.org/t/line-breaks-in-julia/70037/2 "2021-10-19T14:48:13Z")

</div>

No, Julia does _not_ want a line break, it will throw an error.

FWIW this is an _actual_ 2.0 feature I would like to see. Maybe it’s possible before then but I would love a syntax to split things like this onto separate lines.

---

<div class="post-metadata">

**Author:** ![GHL](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@GHL](https://discourse.julialang.org/u/GHL)\
**Post date:** [October 19, 2021, 3:04pm UTC](https://discourse.julialang.org/t/line-breaks-in-julia/70037/3 "2021-10-19T15:04:47Z")

</div>

Unfortunately this is no MWE, so I am not sure wether this works in this case. Did you try enclosing the lines in parentheses?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 19, 2021, 3:07pm UTC](https://discourse.julialang.org/t/line-breaks-in-julia/70037/4 "2021-10-19T15:07:25Z")

</div>

An MWE

```julia
julia> x = [1]; y = [2];

julia> map(x, y) 
       do xx, yy
           xx + yy
       end
ERROR: syntax: invalid "do" syntax
Stacktrace:
 [1] top-level scope
   @ none:1

```

But it is true that wrapping everything in Parentheses works (which is a bit unintuitive)

```julia
julia> (map(x, y) 
       do xx, yy
           xx + yy
       end)
1-element Vector{Int64}:
 3

```

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [October 19, 2021, 3:08pm UTC](https://discourse.julialang.org/t/line-breaks-in-julia/70037/5 "2021-10-19T15:08:57Z")

</div>

On Julia version 1.6, as long as you’re careful to use parentheses when using `&`, you could use the following multi-line syntax (instead of using `map`):

```julia
@. (A > 1) &
   (B > 2) &
   (C > 3)

```

To make my example runnable, here are some values for the variables:

```julia
A = 1:2
B = 2:3
C = 3:4

```

---

<div class="post-metadata">

**Author:** ![GHL](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@GHL](https://discourse.julialang.org/u/GHL)\
**Post date:** [October 19, 2021, 3:11pm UTC](https://discourse.julialang.org/t/line-breaks-in-julia/70037/6 "2021-10-19T15:11:03Z")

</div>

[https://docs.julialang.org/en/v1/manual/noteworthy-differences/](https://docs.julialang.org/en/v1/manual/noteworthy-differences/)

> In Julia, `...` is not used to continue lines of code. Instead, incomplete expressions automatically continue onto the next line.

So also all other incomplete expression will work

```julia
x = 1+
2

```
