I'm new to Crystal, and am working through the documentation as I build out a test project to help me reinforce some of the principles inside Crystal.
I need to be able to iterate x number of times in a loop. The x is arbitrary, not tied to an arrays length, but is a set value at the time of the programs execution.
What's the Crystal way to do this?
I know that I can setup a while
and get the behavior I'm looking for, but is there a specific way this is meant to be implemented in Crystal?
For example, in Ruby, you could say x.times { }
or in Python you could say for num in range(x)
.
There is an x.times {}
in Crystal too.