Proc

Noun · Development

Definitions

  1. In Ruby, a Proc (short for procedure) is an object that encapsulates a block of code, which can be stored in a variable, passed to methods, and called later. Unlike lambdas, procs have relaxed argument checking and different return behavior.

    In plain English: A chunk of Ruby code wrapped up as an object that you can save, pass around, and run whenever you want — like a recipe card you can hand to anyone.

    Example: "square = Proc.new { |x| x ** 2 }; square.call(5) returns 25."

Related Terms