From: Jamis Buck Date: 2004-11-11T03:23:22+09:00 Subject: Re: Converting nil to NULL in a C extension Daniel Berger wrote: > Hi all, > > I find I'm often doing something like this: > > static VALUE foofoo(int argc, VALUE* argv, VALUE self) > char* foo; > VALUE rbFoo; > ... > > rb_scan_args(argc,argv,"01",&rbFoo); > > if(NIL_P(rbFoo)){ > foo = NULL; > } > else{ > foo = StringValuePtr(rbFoo); > } There's always the ternary operator: foo = NIL_P(rbFoo) ? NULL : StringValuePtr(rbFoo); - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis