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
71
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
63
Separating Your Application from Rails - Brian Hughes
lvrug
0
110
SWIG and Ruby - David Grayson
lvrug
0
71
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
120
The Hamster Gem - Ryan Mulligan
lvrug
1
85
Varnish+Redis - Russ Smith
lvrug
1
97
Making Good Use of Fonts - Russ Smith
lvrug
1
82
Writing Files - Ryan Mulligan
lvrug
0
56
Featured
See All Featured
Six Lessons from altMBA
skipperchong
28
4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
A Modern Web Designer's Workflow
chriscoyier
695
190k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
GraphQLとの向き合い方2022年版
quramy
49
14k
We Have a Design System, Now What?
morganepeng
53
7.7k
Scaling GitHub
holman
462
140k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
How to train your dragon (web standard)
notwaldorf
96
6.2k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
183
54k
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