#32 ✓resolved
Rick DeNatale

p 217, lambda and proc

Reported by Rick DeNatale | December 22nd, 2007 @ 09:13 PM | in The Rails 3 Way

The statement is made that the difference between lambda and proc is the that the latter doesn't check the arity of block parameters.

This is not true. Blocks created with either lambda or proc will not complain if they are called with more arguments than they require (even if the number of required arguments is zero), and they will complain if they are called with insufficient arguments. In fact lambda and proc have been aliases for each other for some time.

Also lambda is misspelled as lamda in the last code example on the page.

Comments and changes to this ticket

  • Lark

    Lark January 21st, 2010 @ 11:06 PM

    • State changed from “new” to “open”
    • Assigned user changed from “Obie” to “Lark”

    Thanks for the ticket, Rick. I fixed the misspelling. Will confer with Tim Pope on the arity issue.

  • Lark

    Lark January 28th, 2010 @ 07:24 PM

    • Assigned user changed from “Lark” to “Tim Pope”
  • Tim Pope

    Tim Pope March 10th, 2010 @ 08:11 PM

    • Assigned user changed from “Tim Pope” to “Lark”

    Ruby 1.9 tightens the rules for lambda arguments.

    >> lambda {|x| x}.call(1,2)
    ArgumentError: wrong number of arguments (2 for 1)
    

    Ruby 1.8 works as Rick describes.

  • Obie

    Obie July 12th, 2010 @ 03:58 PM

    • State changed from “open” to “resolved”
    • Milestone order changed from “0” to “0”

    I took care of this.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

People watching this ticket

Pages