# (withdrawn but cannot figure out how to delete my own post)

**URL:** https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048
**Category:** General Usage
**Tags:** question
**Created:** [May 21, 2018, 3:37pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048 "2018-05-21T15:37:09Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)
#### Post date: [May 21, 2018, 3:37pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048/1 "2018-05-21T15:37:09Z")

</div>

nevermind - problem was trailing comma on `for` statement

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [May 21, 2018, 4:02pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048/2 "2018-05-21T16:02:21Z")

</div>

Writing from my mobile so can’t check but you have a comma after the loop range in the first example.

---

<div class="post-metadata">

### Author: ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)
#### Post date: [May 21, 2018, 4:05pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048/3 "2018-05-21T16:05:36Z")

</div>

Thanks. I figured this out while you were answering. Is there some way I can delete my own topic? (embarrassing)

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [May 21, 2018, 4:06pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048/4 "2018-05-21T16:06:28Z")

</div>

No, you will forever live with the shame of having once made a typo in your code. 😉

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [May 21, 2018, 5:18pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048/5 "2018-05-21T17:18:26Z")

</div>

This is actually a fairly common roadblock — one of the best reasons not to delete it is that you’re adding more search fodder for the next time someone else hits it:

> <https://stackoverflow.com/questions/47144058/julia-loop-with-variable-bound-gives-invalid-index>

> <https://github.com/JuliaLang/julia/issues/16075>
>
> The following would be great to capture in some kind of error
> 
> \`\`\` jl
> julia\> r =… ones(1,1)
> 1x1 Array{Float64,2}:
> 1.0
> 
> julia\> for r(i) = b(prow(i))
> end
> 
> julia\> r
> svec()
> \`\`\`
> 
> This came up in code translated from Matlab
> 
> \`\`\` jl
> for i = 1:m,
> r(i) = b(prow(i)); 
> end
> \`\`\`
> 
> where removing the comma gives a reasonable error message. I think I've seen a similar issue with our fancy nested loop syntax before.
> 
> Update: This is on 0.4. It gives an error in 0.5. Would it be possible to fix easily on 0.4?

> <https://github.com/JuliaLang/julia/issues/11222>
>
> Discovered by Bernie Wang:
> 
> The \`for\` syntax ending in a comma is invalid synta…x
> but the first code below yields the scalar 5.0 while the 
> second correctly gives invalid syntax
> 
> \`\`\` jl
> a = zeros(2)
> for i=1:5,
> a += \[1,1\]
> end
> a
> \`\`\`
> 
> \`\`\`
> a = zeros(2)
> for i=1:5,
> a = a + \[1,1\]
> end
> a
> \`\`\`

(Note that the last two there are authored by core contributors)

---

<div class="post-metadata">

### Author: ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)
#### Post date: [May 21, 2018, 8:58pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048/6 "2018-05-21T20:58:28Z")

</div>

Thanks for making me feel a little better. I’m a long-time Matlab user, and many for-loop examples in that language use a trailing comma. I just did a little experiment in Matlab R2016b, and found that you can use a comma, semicolon, or just a space — even if the for-loop is all on one line, e.g.

```
>> for i=1:10 i, end
>> for i=1:10, i, end
>> for i=1:10; i, end

```

These are all syntactically okay, and execute the same way. Most of my lines of Matlab code end in semicolons to prevent the dreaded large-matrix scrolling-output problem, and I substitute commas when debugging to print intermediate values. Not sure why I got in the (bad) habit of the trailing comma on for-loops, if-blocks, etc. They might’ve been necessary in earlier versions . . .

---

<div class="post-metadata">

### Author: ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)
#### Post date: [May 21, 2018, 9:05pm UTC](https://discourse.julialang.org/t/withdrawn-but-cannot-figure-out-how-to-delete-my-own-post/11048/7 "2018-05-21T21:05:17Z")

</div>

Interestingly, a trailing semicolon is valid in Julia:

```
julia> for i in 1:10 @show i end
julia> for i in 1:10; @show i end

```

Both lines do the same thing, whereas

```
julia> for i in 1:10, @show i end

```

produces a syntax error.
