While loop


Why I can’t use the curly braces ( { } ) in place of do and end in a while loop? I got an error every time I try to use it, and I had to resort to using do and end word.

For example:

i = 1

while i <= 50 {
print i
i += 1


programming languages are also “just code”, so decisions are made about how certain concepts are implemented in a language, like the creator of rubys decide that they wanted while do end for the while loop, and no curly brackets

with some googling, you might be able to figure out why they choice this.


I revisited the code earlier and turned out that only the loop method use do and end keyword, which are interchangeable with the curly brackets. Thanks for the reply.