Skip to content

Instantly share code, notes, and snippets.

Sam Stephenson sstephenson

View GitHub Profile
mislav /
Last active Mar 19, 2019
Jim Weirich on the differences between procs and lambdas in Ruby

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

View rbenv.bash
local cur commands
commands="exec prefix rehash set-default set-local version versions\
whence which"
COMPREPLY=( $( compgen -W "${commands}" -- ${cur} ) )
You can’t perform that action at this time.