# For loop is not working in crystal get an error

**URL:** <https://forum.crystal-lang.org/t/for-loop-is-not-working-in-crystal-get-an-error/5931>\
**Category:** Help & Support\
**Created:** [August 12, 2023, 4:39pm UTC](https://forum.crystal-lang.org/t/for-loop-is-not-working-in-crystal-get-an-error/5931 "2023-08-12T16:39:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [August 12, 2023, 4:51pm UTC](https://forum.crystal-lang.org/t/for-loop-is-not-working-in-crystal-get-an-error/5931/4 "2023-08-12T16:51:46Z")

</div>

For loops _are_ a thing, but only in the macro context: [Macros - Crystal](https://crystal-lang.org/reference/1.9/syntax_and_semantics/macros/index.html#iteration). The primary reason for the difference is macros are somewhat special in that they need access to the program itself for code generation reasons.

Related: [Is there a reason why loops using the « for » keyword are not implemented in Crystal?](https://forum.crystal-lang.org/t/is-there-a-reason-why-loops-using-the-for-keyword-are-not-implemented-in-crystal/4095)

P.S. Could also do like:

```crystal
1.upto 10 do |i|
  puts i
end

```

---

_[View the full topic](https://forum.crystal-lang.org/t/for-loop-is-not-working-in-crystal-get-an-error/5931)._
