Ruby - Blocks, Procs, and Lambdas
What will be the output of the following Ruby code?
def greet
yield("Alice")
end
greet { |name| puts "Hello, #{name}!" }def greet
yield("Alice")
end
greet { |name| puts "Hello, #{name}!" }greet calls yield with the string "Alice" as argument, passing it to the block.name and prints "Hello, Alice!".15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions