Introduction

You must place the opening block delimiter on the same line as the method with which it is associated.

For example, these are okay:

Demo

3.times do |i|
    puts( i )# from w w  w  . j  ava 2 s .  c om
end

3.times { |i|
    puts( i )
}

Result

But these contain syntax errors:

Demo

3.times
do |i|          #has syntax errors
    puts( i )#  w  w  w .  ja  v  a  2 s . c  o m
end

3.times
{ |i|           #has syntax errors
    puts( i )
}

Result

Related Topic