diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-26 05:54:18 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-26 05:54:18 +0000 |
| commit | 3217285e9f34614814ab9460b3b2158337d726e1 (patch) | |
| tree | f0417772ac47c5727f52a7f31c1192fdd0a5cf6e /numeric.c | |
| parent | eff4ec072e7e148f4e1c3cc0344a2182c21f490c (diff) | |
merges r20918 from trunk into ruby_1_9_1.
* numeric.c (int_ord): Integer#ord implemented.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
| -rw-r--r-- | numeric.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1925,6 +1925,26 @@ int_chr(int argc, VALUE *argv, VALUE num) return str; } +/* + * call-seq: + * int.ord => int + * + * Returns the int itself. + * + * ?a.ord #=> 97 + * + * This method is intended for compatibility to + * character constant in Ruby 1.9. + * For example, ?a.ord returns 97 both in 1.8 and 1.9. + */ + +static VALUE +int_ord(num) + VALUE num; +{ + return num; +} + static VALUE int_numerator(VALUE num) { @@ -3123,6 +3143,7 @@ Init_Numeric(void) rb_define_method(rb_cInteger, "next", int_succ, 0); rb_define_method(rb_cInteger, "pred", int_pred, 0); rb_define_method(rb_cInteger, "chr", int_chr, -1); + rb_define_method(rb_cInteger, "ord", int_ord, 0); rb_define_method(rb_cInteger, "to_i", int_to_i, 0); rb_define_method(rb_cInteger, "to_int", int_to_i, 0); rb_define_method(rb_cInteger, "floor", int_to_i, 0); |
