11. How do you pass a proc as an argument to a method in Ruby? A. By prefixing the proc variable with a hash # B. By using the pass_proc method C. By prefixing the proc variable with an ampersand & D. By enclosing the proc variable in parentheses () 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
12. What happens if a block is passed to a method that doesn't expect one in Ruby? A. It silently ignores the block B. It converts the block into a proc and passes it as an argument C. It converts the block into a lambda and passes it as an argument D. It raises an error 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
13. What does the lambda? method do in Ruby? A. Checks if an object is a lambda B. Invokes a lambda C. Converts a block into a lambda D. Converts a proc into a lambda 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
14. What does the block_given? method do in Ruby? A. Checks if a proc has been passed to the current method B. Checks if a lambda has been passed to the current method C. Checks if a method has been passed to the current block D. Checks if a block has been passed to the current method 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
15. In Ruby, what is the difference between a proc and a lambda? A. Procs perform strict argument checking, while lambdas do not B. Lambdas can accept a variable number of arguments, while procs cannot C. Lambdas perform strict argument checking, while procs do not D. Procs can accept a variable number of arguments, while lambdas cannot 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
16. Which keyword is used to define a block in Ruby? A. block B. do C. None of the above D. block 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
17. What happens if you try to yield to a block that does not exist in Ruby? A. An IOError is raised B. A SyntaxError is raised C. A NoMethodError is raised D. An ArgumentError is raised 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
18. Which method is used to convert a block into a proc in Ruby? A. Proc.new B. & C. None of the above D. .to_proc 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
19. What does the yield keyword do in Ruby? A. Executes the block passed to the method B. Returns the value of the block passed to the method C. Exits the method and returns to the caller D. None of the above 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
20. Which method is used to check if a block has been passed to a Ruby method? A. block_exists? B. block_present? C. has_block? D. block_given? 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