So, Ruby is a bit weird: the Ruby community itself tends to be much closer to Perl than Python, that is, the language doesn't mind embracing many ways of doing the same thing. However, the Rails community tends to curb this attitude a bit by being really strongly about conventions, and following them.
In practice, this means that a significant amount of the community uses one of the two rules:
> Use {} for one line blocks, use do/end for multiline blocks.
or
> Use {} for blocks that produce a value, use do/end for side effects.
The latter is called "Weirich style," after a very prominent Rubyist using that style.
Hilariously, your example would be code that could go either way, depending on which style you choose. Though I would think that people who subscribe to the first rule would write it
3.times { print 'Welcome ' }
as the "one line" really kinda leans this way.
Anyway that's as far as I know, my Ruby knowledge is about 10 years old at this point, so maybe things have evolved since then, but I haven't really heard of any changes here.
So, Ruby is a bit weird: the Ruby community itself tends to be much closer to Perl than Python, that is, the language doesn't mind embracing many ways of doing the same thing. However, the Rails community tends to curb this attitude a bit by being really strongly about conventions, and following them.
In practice, this means that a significant amount of the community uses one of the two rules:
> Use {} for one line blocks, use do/end for multiline blocks.
or
> Use {} for blocks that produce a value, use do/end for side effects.
The latter is called "Weirich style," after a very prominent Rubyist using that style.
Hilariously, your example would be code that could go either way, depending on which style you choose. Though I would think that people who subscribe to the first rule would write it
as the "one line" really kinda leans this way.Anyway that's as far as I know, my Ruby knowledge is about 10 years old at this point, so maybe things have evolved since then, but I haven't really heard of any changes here.