1. What is a block in Ruby? A. A chunk of code that can be passed to methods as an argument B. A data structure for storing multiple values C. A special type of object that holds code to be executed D. A method that can be invoked with different arguments Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
2. How do you define a block in Ruby? A. By using the keyword block followed by square brackets [] B. By using the keyword block followed by parentheses () C. By defining a method with the keyword block D. By enclosing code within curly braces {} Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
3. What is a proc in Ruby? A. A method that takes no arguments B. A predefined set of instructions C. A block that has been converted into an object D. A data structure for storing key-value pairs Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
4. How do you create a proc in Ruby? A. By using the create_proc function B. Using the Proc.new method or the -> (stabby lambda) syntax C. By invoking the proc keyword followed by parentheses () D. By using the create_proc function Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
5. What is the difference between a block and a proc in Ruby? A. A proc can be passed directly to methods, while a block needs to be converted into an object B. A proc is an anonymous function, while a block is a named function C. A block can be passed directly to methods, while a proc needs to be converted into an object D. A block is an anonymous function, while a proc is a named function Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
6. How do you call a block in Ruby? A. By invoking it with parentheses () B. By using the call method C. By passing it as an argument to a method D. By passing it to a method using the yield keyword Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
7. What is a lambda in Ruby? A. A type of anonymous function similar to a proc, but with stricter argument checking B. A block of code that is passed to methods as an argument C. A predefined set of instructions D. A method that takes no arguments Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
8. How do you define a lambda in Ruby? A. By using the create_lambda function B. By defining a method with the keyword lambda C. Using the lambda keyword followed by curly braces {} D. By using the -> (stabby lambda) syntax Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
9. What does the & operator do when used with a proc in Ruby? A. Invokes the proc with the given arguments B. Converts the proc into a lambda so it can be passed to a method that expects a lambda parameter C. Converts the proc into a block so it can be passed to a method that expects a block parameter D. Converts the proc into a method so it can be called directly Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
10. What is the purpose of using blocks and procs in Ruby? A. To create new instances of classes B. To encapsulate and pass around chunks of code C. To handle file input and output D. To create new instances of classes Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board