Blocks And Procs In Ruby - Study Mode
[#1] What is a block in Ruby?
Correct Answer
(A) A chunk of code that can be passed to methods as an argument
[#2] How do you define a block in Ruby?
Correct Answer
(D) By enclosing code within curly braces {}
[#3] What is a proc in Ruby?
Correct Answer
(C) A block that has been converted into an object
[#4] How do you create a proc in Ruby?
Correct Answer
(B) Using the Proc.new method or the -> (stabby lambda) syntax
[#5] What is the difference between a block and a proc in Ruby?
Correct Answer
(C) A block can be passed directly to methods, while a proc needs to be converted into an object