Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
99
0
Share
Lambdas and Pops - Jan Hettich
Las Vegas Ruby Group
June 18, 2014
More Decks by Las Vegas Ruby Group
See All by Las Vegas Ruby Group
Ruby ISO Standard - David Grayson
lvrug
0
150
Windows Automation - Howard Feldman
lvrug
0
100
Separating Your Application from Rails - Brian Hughes
lvrug
0
150
SWIG and Ruby - David Grayson
lvrug
0
93
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
140
The Hamster Gem - Ryan Mulligan
lvrug
1
110
Varnish+Redis - Russ Smith
lvrug
1
130
Making Good Use of Fonts - Russ Smith
lvrug
1
110
Writing Files - Ryan Mulligan
lvrug
0
83
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.8k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
170
sira's awesome portfolio website redesign presentation
elsirapls
0
210
Building Adaptive Systems
keathley
44
3k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
270
Context Engineering - Making Every Token Count
addyosmani
9
820
The Curious Case for Waylosing
cassininazir
0
300
Paper Plane (Part 1)
katiecoart
PRO
0
6.6k
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