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
49
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
42
Separating Your Application from Rails - Brian Hughes
lvrug
0
94
SWIG and Ruby - David Grayson
lvrug
0
51
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
110
The Hamster Gem - Ryan Mulligan
lvrug
1
79
Varnish+Redis - Russ Smith
lvrug
1
80
Making Good Use of Fonts - Russ Smith
lvrug
1
62
Writing Files - Ryan Mulligan
lvrug
0
39
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Optimizing for Happiness
mojombo
376
70k
RailsConf 2023
tenderlove
29
970
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
4 Signs Your Business is Dying
shpigford
182
22k
Writing Fast Ruby
sferik
628
61k
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