In macruby what does Module's method "__type__" do? -


module macruby has several ways that are not usually. One of these is __ type __ and I can not understand what it does. What does it do?

Thank you!

z

__ type __ is defined in object.c: < / P>

  static VALUE rb_obj_type (VALUE obj) {return LONG2FIX (TYPE (obj)); }   

which in turn depends on the rb_type function:

  static inline Inc. rb_type (VALUE obj) {if ( IMMEDIATE_P (Obj)) {if (FIXNUM_P (obj)) {return T_FIXNUM; } If (FIXFLOAT_P (obj)) {return T_FLOAT; } If (obj == Qtrue) {return T_TRUE; } If (obj == Qundef) {return T_UNDEF; }} And if (! RTEST (obj)) {if (obj == Qnil) {return T_NIL; } If (obj == Qfalse) {return T_FALSE; }} Return rb_objc_type (obj); }   

Of course, it only returns a number that matches a type identifier, as defined by the pre-compiler constant T_FIXNUM, T_FLOAT, etc.

I would say that this is really some of limited use for standard users, however, when you write a C extension, it can check your code more efficient type.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -