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
30d7c60c
Commit
30d7c60c
authored
Dec 03, 2012
by
Yukihiro Matz Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Array#[]= should return assigning value; close #584
parent
97545127
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
10 deletions
+7
-10
src/array.c
src/array.c
+5
-8
test/t/array.rb
test/t/array.rb
+2
-2
No files found.
src/array.c
View file @
30d7c60c
...
@@ -719,24 +719,21 @@ mrb_ary_aset(mrb_state *mrb, mrb_value self)
...
@@ -719,24 +719,21 @@ mrb_ary_aset(mrb_state *mrb, mrb_value self)
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
argc
);
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
argc
);
switch
(
argc
)
{
switch
(
argc
)
{
case
2
:
case
2
:
if
(
mrb_fixnum_p
(
argv
[
0
]))
{
if
(
!
mrb_fixnum_p
(
argv
[
0
]))
{
mrb_ary_set
(
mrb
,
self
,
mrb_fixnum
(
argv
[
0
]),
argv
[
1
]);
}
else
{
/* Should we support Range object for 1st arg ? */
/* Should we support Range object for 1st arg ? */
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"expected Fixnum for 1st argument"
);
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"expected Fixnum for 1st argument"
);
}
}
break
;
mrb_ary_set
(
mrb
,
self
,
mrb_fixnum
(
argv
[
0
]),
argv
[
1
]);
return
argv
[
1
];
case
3
:
case
3
:
mrb_ary_splice
(
mrb
,
self
,
mrb_fixnum
(
argv
[
0
]),
mrb_fixnum
(
argv
[
1
]),
argv
[
2
]);
mrb_ary_splice
(
mrb
,
self
,
mrb_fixnum
(
argv
[
0
]),
mrb_fixnum
(
argv
[
1
]),
argv
[
2
]);
break
;
return
argv
[
2
]
;
default:
default:
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"wrong number of arguments"
);
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"wrong number of arguments"
);
return
mrb_nil_value
();
}
}
return
self
;
}
}
mrb_value
mrb_value
...
...
test/t/array.rb
View file @
30d7c60c
...
@@ -74,8 +74,8 @@ assert('Array#[]=', '15.2.12.5.5') do
...
@@ -74,8 +74,8 @@ assert('Array#[]=', '15.2.12.5.5') do
e3
=
e1
e3
=
e1
end
end
[
1
,
2
,
3
].
[
]
=
(
1
,
4
)
==
[
1
,
4
,
3
]
and
[
1
,
2
,
3
].
[
]
=
(
1
,
4
)
==
4
and
[
1
,
2
,
3
].
[
]
=
(
1
,
2
,
3
)
==
[
1
,
3
]
and
[
1
,
2
,
3
].
[
]
=
(
1
,
2
,
3
)
==
3
and
e2
.
class
==
ArgumentError
and
e2
.
class
==
ArgumentError
and
e3
.
class
==
ArgumentError
e3
.
class
==
ArgumentError
end
end
...
...
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