Different syntaxes for Proc


#1




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
end

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


#2

No difference, considering they are both blocks.


#3

I have noticed that in


only the second kind of syntax works.


#4

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


#5

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

3.times do |i|
     puts i
end

and

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.


#6