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 Png genki on Tue 6 Mar 2007 at 10:10
Contents
Ruby拡張の中でHashをiterateする方法
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ