Different syntaxes for Proc


According to the other exercises, the Proc should be written as

over_4_feet = Proc.new { |height| height >= 4 }

and that passes, but in the Hints, it says to use

over_4_feet = Proc.new do |height|
  # Include rest of block code here

What is the difference, if any?
I just wanted to know.


No difference, considering they are both blocks.


I have noticed that in

only the second kind of syntax works.


That's funny, they both work for me, and both pass. How are you calling it?


basically, {} and do --- end are two different styles of writing block.
its just the same way we write

3.times do |i|
     puts i


3.times {|i| puts i}

essentially, both of them does the same task. its just way of writing same loop in different style.

body of Proc can be written in '{}' format or 'do...end' format. just do what suites you.