シンボルとIDと文字列
最終更新:
tmtbnc
-
view
Rubyのシンボル
#define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
#define SYM2ID(x) RSHIFT((unsigned long)x,8)
ID rb_intern _((const char*));
const char *rb_id2name _((ID));
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
VALUE rb_str_new2 _((const char*));
VALUE rb_str_intern _((VALUE));
VALUE sym_to_s(VALUE sym)
rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0);
rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0);
Links
第3章 名前と名前表
http://i.loveruby.net/ja/rhg/book/name.html
http://i.loveruby.net/ja/rhg/book/name.html