Examveda

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: Option C


This Question Belongs to Ruby Programming >> Blocks And Procs In Ruby

Join The Discussion

Related Questions on Blocks and Procs in Ruby

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

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 {}

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

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. None of the above