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
0
66
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
120
Windows Automation - Howard Feldman
lvrug
0
60
Separating Your Application from Rails - Brian Hughes
lvrug
0
110
SWIG and Ruby - David Grayson
lvrug
0
68
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
120
The Hamster Gem - Ryan Mulligan
lvrug
1
82
Varnish+Redis - Russ Smith
lvrug
1
95
Making Good Use of Fonts - Russ Smith
lvrug
1
79
Writing Files - Ryan Mulligan
lvrug
0
53
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Rails Girls Zürich Keynote
gr2m
95
14k
Why Our Code Smells
bkeepers
PRO
336
57k
Speed Design
sergeychernyshev
32
1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Building Adaptive Systems
keathley
43
2.7k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Being A Developer After 40
akosma
90
590k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
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