Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Lambdas and Pops - Jan Hettich
Search
Las Vegas Ruby Group
June 18, 2014
0
86
Lambdas and Pops - Jan Hettich
Las Vegas Ruby Group
June 18, 2014
Tweet
Share
More Decks by Las Vegas Ruby Group
See All by Las Vegas Ruby Group
Ruby ISO Standard - David Grayson
lvrug
0
140
Windows Automation - Howard Feldman
lvrug
0
78
Separating Your Application from Rails - Brian Hughes
lvrug
0
130
SWIG and Ruby - David Grayson
lvrug
0
84
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
130
The Hamster Gem - Ryan Mulligan
lvrug
1
98
Varnish+Redis - Russ Smith
lvrug
1
110
Making Good Use of Fonts - Russ Smith
lvrug
1
95
Writing Files - Ryan Mulligan
lvrug
0
70
Featured
See All Featured
The Language of Interfaces
destraynor
162
25k
Balancing Empowerment & Direction
lara
5
790
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
Building Applications with DynamoDB
mza
96
6.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
The Cult of Friendly URLs
andyhume
79
6.7k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Transcript
λ's and POP's Jan Hettich LVRUG 5/21/2014
Two kinds of Proc “plain old proc” lambda closure? yes
yes class Proc Proc .lambda? false true semantics yield invocation similar to block method
Creation • “Plain old procs” • Kernel.proc {|args| code} •
Proc.new {|args| code} • Lambdas • Kernel.lambda {|args| code} • literal: ->(args) {code} • Method.to_proc
call syntax • direct call – foo.call(args) – foo[args] –
foo.(args) • block-style call – iterator args, &foo
call semantics • yield semantics (blocks, pops) • similar to
parallel assignment • return => lexically enclosing method • invocation semantics (methods, lambdas) • number of arguments must match • “diminutive return”
Let's look at some code • A Digression on Method
• Argument Passing • return statement • Using next • New behavior in Ruby 2.1.0