TIL a Ruby proc/lambda can be called via square-bracket notation

Oliver Peate posted on May 21st, 2020

greeter = Proc.new { |name| puts "Hi #{name}" }
greeter["Bob"] # Hi Bob

This opens up the possibility of using a proc or lambda interchangeably with a hash.


What did you learn today?

Write a quick TIL post to reflect on what you've learned.

Write a post