# Lambda arguments in an extension

**URL:** <https://www.ruby-forum.com/t/lambda-arguments-in-an-extension/114427>\
**Category:** Ruby\
**Created:** [September 12, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/lambda-arguments-in-an-extension/114427 "2007-09-12T16:12:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 12, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/lambda-arguments-in-an-extension/114427/1 "2007-09-12T16:12:41Z")

</div>

In an extension, how do I differentiate between:

lambda().call()

and:

lambda().call(nil)

Here’s some sample code that demonstrates the problem:

[pbrannan@zaphod tmp]$ cat test.rb  
require ‘test.so’

foo()

[pbrannan@zaphod tmp]$ cat test.c  
#include “ruby.h”

VALUE iter(VALUE obj)  
{  
VALUE l = rb\_funcall(rb\_cObject, rb\_intern(“lambda”), 0);  
rb\_funcall(l, rb\_intern(“call”), 0);  
rb\_funcall(l, rb\_intern(“call”), 1, Qnil);  
rb\_funcall(l, rb\_intern(“call”), 1, INT2NUM(42));  
}

VALUE body(VALUE obj, VALUE data)  
{  
rb\_p(obj);  
return Qnil;  
}

static VALUE foo(VALUE self)  
{  
rb\_iterate(RUBY\_METHOD\_FUNC(iter), Qnil, RUBY\_METHOD\_FUNC(body),  
Qnil);  
}

void Init\_test()  
{  
rb\_define\_method(rb\_cObject, “foo”, foo, 0);  
}

[pbrannan@zaphod tmp]$ cat extconf.rb  
require ‘mkmf’  
create\_makefile(‘test’)  
[pbrannan@zaphod tmp]$ ruby test.rb  
nil  
nil  
42
