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
52
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
110
Windows Automation - Howard Feldman
lvrug
0
45
Separating Your Application from Rails - Brian Hughes
lvrug
0
97
SWIG and Ruby - David Grayson
lvrug
0
54
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
110
The Hamster Gem - Ryan Mulligan
lvrug
1
80
Varnish+Redis - Russ Smith
lvrug
1
84
Making Good Use of Fonts - Russ Smith
lvrug
1
65
Writing Files - Ryan Mulligan
lvrug
0
42
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Building Adaptive Systems
keathley
40
2.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
550
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Automating Front-end Workflow
addyosmani
1368
200k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
Scaling GitHub
holman
459
140k
Mobile First: as difficult as doing things right
swwweet
223
9.3k
Side Projects
sachag
452
42k
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