U:RDoc::AnyMethod[iI" lambda?:ETI"Proc#lambda?;TF: publico:RDoc::Markup::Document: @parts[/o:RDoc::Markup::Paragraph; [I"LReturns +true+ for a Proc object for which argument handling is rigid. ;TI"4Such procs are typically generated by +lambda+.;To:RDoc::Markup::BlankLineo; ; [I"?A Proc object generated by +proc+ ignores extra arguments.;T@o:RDoc::Markup::Verbatim; [I"2proc {|a,b| [a,b] }.call(1,2,3) #=> [1,2] ;T: @format0o; ; [I"-It provides +nil+ for missing arguments.;T@o; ; [I"4proc {|a,b| [a,b] }.call(1) #=> [1,nil] ;T; 0o; ; [I"(It expands a single array argument.;T@o; ; [I"2proc {|a,b| [a,b] }.call([1,2]) #=> [1,2] ;T; 0o; ; [I"BA Proc object generated by +lambda+ doesn't have such tricks.;T@o; ; [I":lambda {|a,b| [a,b] }.call(1,2,3) #=> ArgumentError ;TI":lambda {|a,b| [a,b] }.call(1) #=> ArgumentError ;TI":lambda {|a,b| [a,b] }.call([1,2]) #=> ArgumentError ;T; 0o; ; [I"1Proc#lambda? is a predicate for the tricks. ;TI"*It returns +true+ if no tricks apply.;T@o; ; [I"+lambda {}.lambda? #=> true ;TI",proc {}.lambda? #=> false ;T; 0o; ; [I"$Proc.new is the same as +proc+.;T@o; ; [I",Proc.new {}.lambda? #=> false ;T; 0o; ; [I":+lambda+, +proc+ and Proc.new preserve the tricks of ;TI"4a Proc object given by & argument.;T@o; ; [ I"+lambda(&lambda {}).lambda? #=> true ;TI"+proc(&lambda {}).lambda? #=> true ;TI"+Proc.new(&lambda {}).lambda? #=> true ;TI" ;TI",lambda(&proc {}).lambda? #=> false ;TI",proc(&proc {}).lambda? #=> false ;TI",Proc.new(&proc {}).lambda? #=> false ;T; 0o; ; [I"FA Proc object generated by & argument has the tricks;T@o; ; [I"def n(&b) b.lambda? end ;TI",n {} #=> false ;T; 0o; ; [I"GThe & argument preserves the tricks if a Proc object ;TI")is given by & argument.;T@o; ; [I"+n(&lambda {}) #=> true ;TI",n(&proc {}) #=> false ;TI",n(&Proc.new {}) #=> false ;T; 0o; ; [I"9A Proc object converted from a method has no tricks.;T@o; ; [ I"def m() end ;TI"+method(:m).to_proc.lambda? #=> true ;TI" ;TI"+n(&method(:m)) #=> true ;TI"+n(&method(:m).to_proc) #=> true ;T; 0o; ; [I"?+define_method+ is treated the same as method definition. ;TI"&The defined method has no tricks.;T@o; ; [ I" class C ;TI" define_method(:d) {} ;TI" end ;TI"*C.new.d(1,2) #=> ArgumentError ;TI"1C.new.method(:d).to_proc.lambda? #=> true ;T; 0o; ; [I"A+define_method+ always defines a method without the tricks, ;TI"0even if a non-lambda Proc object is given. ;TI"GThis is the only exception for which the tricks are not preserved.;T@o; ; [ I" class C ;TI"# define_method(:e, &proc {}) ;TI" end ;TI"*C.new.e(1,2) #=> ArgumentError ;TI"1C.new.method(:e).to_proc.lambda? #=> true ;T; 0o; ; [I";This exception ensures that methods never have tricks ;TI"Oand makes it easy to have wrappers to define methods that behave as usual.;T@o; ; [ I" class C ;TI"" def self.def2(name, &body) ;TI"$ define_method(name, &body) ;TI" end ;TI" ;TI" def2(:f) {} ;TI" end ;TI"*C.new.f(1,2) #=> ArgumentError ;T; 0o; ; [I"BThe wrapper def2 defines a method which has no tricks.;T: @fileI" proc.c;T:0@omit_headings_from_table_of_contents_below0I""prc.lambda? -> true or false ;T0[I"();T@‚FI" Proc;TcRDoc::NormalClass00