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
46
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
100
Windows Automation - Howard Feldman
lvrug
0
40
Separating Your Application from Rails - Brian Hughes
lvrug
0
91
SWIG and Ruby - David Grayson
lvrug
0
49
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
100
The Hamster Gem - Ryan Mulligan
lvrug
1
78
Varnish+Redis - Russ Smith
lvrug
1
78
Making Good Use of Fonts - Russ Smith
lvrug
1
60
Writing Files - Ryan Mulligan
lvrug
0
37
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
3k
Bash Introduction
62gerente
608
210k
Making Projects Easy
brettharned
116
5.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Site-Speed That Sticks
csswizardry
2
190
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
BBQ
matthewcrist
85
9.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
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