The Ultimate Guide to Blocks, Procs & Lambdas

Hello,
I wrote this post where I explain the subtle differences between procs &
lambdas, and how closures work in Ruby.

Please check it out:

Let me know what you think :slight_smile:

Hey Jesus,

Nice summary! I'd agree with one of the other commenters that you may want to include Proc.new's behavior which is commonly used to lazily capture the block (let's you evaluate your guard clauses before capturing the block for example)

You may also want to give an example of forwarding a block to another method

If block_given?
  other.do_stuff &Proc.new
else
  other.do_stuff
end

Josh

ยทยทยท

Sent from my iPhone

On Feb 8, 2016, at 8:56 AM, Jesus Castello <matugm@gmail.com> wrote:

Hello,
I wrote this post where I explain the subtle differences between procs & lambdas, and how closures work in Ruby.

Please check it out:

Ruby Blocks, Procs & Lambdas - The Ultimate Guide!

Let me know what you think :slight_smile:

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Simple, clear, powerful !

I am a novice in Ruby and you're guide is very operative to understand
blocks.

From a noob, a big thanks !

Hello, Jesus!

Nice article. thanks for sharing!

May I suggest to include the info from the article Passing Blocks in Ruby
Without &block
<http://mudge.name/2011/01/26/passing-blocks-in-ruby-without-block.html&gt;
as a good practice?
Also, the 1st comment to the article shows how to use only yield when
passing the block to methods.

<http://mudge.name/2011/01/26/passing-blocks-in-ruby-without-block.html&gt;

ยทยทยท

--
Sincerely yours,

Aurel Branzeanu,

mailto: branzeanu.aurel@gmail.com
Skype: tvorogov
GSM Orange: +373 6 940-7700
GSM Moldcell: +373 7 940-7700

On Mon, Feb 8, 2016 at 3:56 PM, Jesus Castello <matugm@gmail.com> wrote:

Hello,
I wrote this post where I explain the subtle differences between procs &
lambdas, and how closures work in Ruby.

Please check it out:

Ruby Blocks, Procs & Lambdas - The Ultimate Guide!

Let me know what you think :slight_smile:

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Nicely written and formatted! I could not spare you some minor
nitpicking (we're always trying to improve things, aren't we?). :wink:

Kind regards

robert

ยทยทยท

On Mon, Feb 8, 2016 at 2:56 PM, Jesus Castello <matugm@gmail.com> wrote:

Hello,
I wrote this post where I explain the subtle differences between procs &
lambdas, and how closures work in Ruby.

Please check it out:

Ruby Blocks, Procs & Lambdas - The Ultimate Guide!

Let me know what you think :slight_smile:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

Quiet awesome man, it was published in Ruby Weekly and I read it.

ยทยทยท

On Monday 08 February 2016 07:26 PM, Jesus Castello wrote:

Hello,
I wrote this post where I explain the subtle differences between procs & lambdas, and how closures work in Ruby.

Please check it out:

Ruby Blocks, Procs & Lambdas - The Ultimate Guide!

Let me know what you think :slight_smile:

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K

subscribe too.

ยทยทยท

8 ั„ะตะฒั€. 2016 ะณ., ะฒ 18:28, Karthikeyan A K <karthikeyan@openmailbox.org> ะฝะฐะฟะธัะฐะป(ะฐ):

Quiet awesome man, it was published in Ruby Weekly and I read it.

On Monday 08 February 2016 07:26 PM, Jesus Castello wrote:

Hello,
I wrote this post where I explain the subtle differences between procs & lambdas, and how closures work in Ruby.

Please check it out:

Ruby Blocks, Procs & Lambdas - The Ultimate Guide!

Let me know what you think :slight_smile:

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe> <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt; <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;