1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* object.c (rb_check_to_int): new function to convert a VALUE to

an Integer if possible, but returns nil instead of raising an
  exception otherwise.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-12-11 01:37:50 +00:00
parent 0468b1bd6a
commit c5fc4da7a2
3 changed files with 13 additions and 0 deletions

View file

@ -1,3 +1,9 @@
Sun Dec 11 10:37:47 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* object.c (rb_check_to_int): new function to convert a VALUE to
an Integer if possible, but returns nil instead of raising an
exception otherwise.
Sun Dec 11 10:34:39 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Dec 11 10:34:39 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (rb_exit_status_code): extract from rb_f_exit_bang and * process.c (rb_exit_status_code): extract from rb_f_exit_bang and

View file

@ -553,6 +553,7 @@ VALUE rb_check_convert_type(VALUE,int,const char*,const char*);
VALUE rb_check_to_integer(VALUE, const char *); VALUE rb_check_to_integer(VALUE, const char *);
VALUE rb_check_to_float(VALUE); VALUE rb_check_to_float(VALUE);
VALUE rb_to_int(VALUE); VALUE rb_to_int(VALUE);
VALUE rb_check_to_int(VALUE);
VALUE rb_Integer(VALUE); VALUE rb_Integer(VALUE);
VALUE rb_to_float(VALUE); VALUE rb_to_float(VALUE);
VALUE rb_Float(VALUE); VALUE rb_Float(VALUE);

View file

@ -2187,6 +2187,12 @@ rb_to_int(VALUE val)
return rb_to_integer(val, "to_int"); return rb_to_integer(val, "to_int");
} }
VALUE
rb_check_to_int(VALUE val)
{
return rb_check_to_integer(val, "to_int");
}
static VALUE static VALUE
rb_convert_to_integer(VALUE val, int base) rb_convert_to_integer(VALUE val, int base)
{ {