Functional Programming in Ruby
Proc, Lambda, and Beyond
Agnieszka Maลaszkiewicz at Fractal Soft
I joined Ruby community when...
Ruby 1.9.3
Rails 3.0
A lightning talk by
Gary Bernhardt from CodeMash 2012
Agenda
- ๐ข Block
- ๐ Procs
- ๐ Lambdas
- ๐ช Closures
- ๐งโโ๏ธ Crazy stuff
- ๐ Summary
๐ Function
๐ข Block
๐ Proc
๐ค How call Proc object?
๐ผ Proc in case
โ๏ธ Call method with argument as proc
๐ Lambdas
๐งโโ๏ธ Crazy stuff
๐ฆ Call map with argument method
#๏ธโฃ Hash in map
๐ฆ Passing argument to map
๐คฏ
Summary
Types
- ๐ข block + yield
- ๐ block + &b
- ๐ Proc.new
- ๐จโ๐ป proc
- ๐ lambda
- ๐ค method
### Links
- [Wat lightning talk](https://destroyallsoftware.com/talks/wat)
- [parsel.y](https://github.com/ruby/ruby/blob/master/parse.y#L4992-L5000)
- [Why do two strings separated by space concatenate in Ruby?](https://stackoverflow.com/questions/23811203/why-do-two-strings-separated-by-space-concatenate-in-ruby/)
- [Closure in Ruby](http://innig.net/software/ruby/closures-in-ruby)
- [An Introduction to Proc, Lambdas and Closures in Ruby](https://www.youtube.com/watch?v=VBC-G6hahWA)
- [Design Patterns in Ruby - Russ Olsen](http://www.amazon.com/Design-Patterns-Ruby-Russ-Olsen/dp/0321490452)
- [Ruby doc](http://ruby-doc.org/)
- [Functional Programming with Ruby](http://www.slideshare.net/tokland/functional-programming-with-ruby-9975242)
- [Features of Functional Languages](http://www.sitepoint.com/functional-programming-techniques-with-ruby-part-i/)
- [Ruby Proc doc 2.6](https://ruby-doc.org/core-2.6/Proc.html#method-c-new)
### Links
- [Rubinius](https://github.com/rubinius/rubinius)
- [Ruby current Proc doc](https://ruby-doc.org/current/Proc.html)
- [Ruby Proc doc 1.9.1](https://ruby-doc.org/core-1.9.1/Proc.html)
- [Ruby Proc doc 1.8.6](https://ruby-doc.org/core-1.8.6/Proc.html)
- [Method#curry](https://www.rubydoc.info/stdlib/core/Method:curry)
- [Ruby map(&:method) syntax - meaning & usage](https://womanonrails.com/one-line-map-ruby)
- [Method object](https://ruby-doc.org/current/Method.html)
- [Functional programming in Ruby](https://womanonrails.com/functional-programming-ruby)
- [Iterators in Ruby](https://womanonrails.com/ruby-iterators)
- [Things you didn't know about Ruby](https://womanonrails.com/things-you-dont-know-about-ruby)
Agnieszka Maลaszkiewicz
agnieszka (at) fractalsoft (dot) org