6th Tue
Ruby拡張の中でHashをiterateする方法
This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/167
以下は、rb_iterateを使ってHashをiterateするコードです。
static VALUE iterator_proc(VALUE Pair, VALUE Arg, VALUE Self){
VALUE Key = RARRAY(Pair)->ptr[0];
VALUE Value = RARRAY(Pair)->ptr[1];
return Qnil;
}
rb_iterate(rb_each, Hash, iterator_proc, Arg);
HashはiterateされるべきHash、
Argはイテレータ・ブロック関数に渡される任意のVALUEです。
This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/167
posted by
genki on Tue 6 Mar 2007 at 10:10 with 0 comments