NEW
Font size
WorksheetsRuby Fall25-26
Total questions: 10
Worksheet time: 5mins
Ruby loves blocks. Which is the correct way to pass a block to an each method?
array.each[ |x| puts x ]
array.each { |x| puts x }
array.each do puts x end
array.each (x) -> puts x
What’s the difference between a Proc and a Lambda when arguments don’t match?
Both throw errors
Proc ignores, Lambda complains
Lambda ignores, Proc complains
Neither cares
What happens if you use return inside a Proc defined in a method?
Returns from Proc only
Returns from the whole method
Crashes Ruby
Calls your parents
What does this code print?
puts Time.new(2026,1,1).sunday?
True
False
nil
Depends on your laptop clock
Which of these gives you the current time?
start
execute
run
call
How do you create a Lambda in Ruby?
What will this print?
def movie_night
yield "Popcorn"
end
movie_night { |snack| puts "Enjoy your #{snack}!" }
Enjoy your snack!
Error: no block given
nil
Enjoy your Popcorn!
If today is 2025-09-04, what will this print?
puts (Time.now + 60*60*24*7).strftime("%A")
Today’s weekday name
Time travel not supported
Next week’s weekday name
Error
