Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
6d695707
Commit
6d695707
authored
May 25, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no one uses Array.try_convert, so removed it that discourages duck typing; close #2317
parent
229e7fe2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
36 deletions
+0
-36
mrbgems/mruby-array-ext/src/array.c
mrbgems/mruby-array-ext/src/array.c
+0
-31
mrbgems/mruby-array-ext/test/array.rb
mrbgems/mruby-array-ext/test/array.rb
+0
-5
No files found.
mrbgems/mruby-array-ext/src/array.c
View file @
6d695707
...
...
@@ -3,35 +3,6 @@
#include "mruby/array.h"
#include "mruby/range.h"
/*
* 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
...
...
@@ -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
));
...
...
mrbgems/mruby-array-ext/test/array.rb
View file @
6d695707
##
# 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"
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment