diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-25 23:18:45 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-25 23:18:45 +0900 |
| commit | 6d6957078eb56d95af3c729bb172765bf610ef54 (patch) | |
| tree | eeac39cda383e9748f471a72f304c34016ea0eec /mrbgems/mruby-array-ext | |
| parent | 229e7fe245535780fcad83527bfe2e9a09c8c023 (diff) | |
| download | mruby-6d6957078eb56d95af3c729bb172765bf610ef54.tar.gz mruby-6d6957078eb56d95af3c729bb172765bf610ef54.zip | |
no one uses Array.try_convert, so removed it that discourages duck typing; close #2317
Diffstat (limited to 'mrbgems/mruby-array-ext')
| -rw-r--r-- | mrbgems/mruby-array-ext/src/array.c | 31 | ||||
| -rw-r--r-- | mrbgems/mruby-array-ext/test/array.rb | 5 |
2 files changed, 0 insertions, 36 deletions
diff --git a/mrbgems/mruby-array-ext/src/array.c b/mrbgems/mruby-array-ext/src/array.c index ae9d8296e..014137e99 100644 --- a/mrbgems/mruby-array-ext/src/array.c +++ b/mrbgems/mruby-array-ext/src/array.c @@ -5,35 +5,6 @@ /* * call-seq: - * Array.try_convert(obj) -> array or nil - * - * Try to convert <i>obj</i> into an array, using +to_ary+ method. - * Returns converted array or +nil+ if <i>obj</i> cannot be converted - * for any reason. This method can be used to check if an argument is an - * array. - * - * Array.try_convert([1]) #=> [1] - * Array.try_convert("1") #=> nil - * - * if tmp = Array.try_convert(arg) - * # the argument is an array - * elsif tmp = String.try_convert(arg) - * # the argument is a string - * end - * - */ - -static mrb_value -mrb_ary_s_try_convert(mrb_state *mrb, mrb_value self) -{ - mrb_value ary; - - mrb_get_args(mrb, "o", &ary); - return mrb_check_array_type(mrb, ary); -} - -/* - * call-seq: * ary.assoc(obj) -> new_ary or nil * * Searches through an array whose elements are also arrays @@ -139,8 +110,6 @@ mrb_mruby_array_ext_gem_init(mrb_state* mrb) { struct RClass * a = mrb->array_class; - mrb_define_class_method(mrb, a, "try_convert", mrb_ary_s_try_convert, MRB_ARGS_REQ(1)); - mrb_define_method(mrb, a, "assoc", mrb_ary_assoc, MRB_ARGS_REQ(1)); mrb_define_method(mrb, a, "at", mrb_ary_at, MRB_ARGS_REQ(1)); mrb_define_method(mrb, a, "rassoc", mrb_ary_rassoc, MRB_ARGS_REQ(1)); diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb index 1fa7cfc04..cb5652dde 100644 --- a/mrbgems/mruby-array-ext/test/array.rb +++ b/mrbgems/mruby-array-ext/test/array.rb @@ -1,11 +1,6 @@ ## # Array(Ext) Test -assert("Array::try_convert") do - assert_equal [1], Array.try_convert([1]) - assert_nil Array.try_convert("1") -end - assert("Array#assoc") do s1 = [ "colors", "red", "blue", "green" ] s2 = [ "letters", "a", "b", "c" ] |
