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
898077a2
Commit
898077a2
authored
7 years ago
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
7 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3566 from okkez/fix-enumerator-each-with-index
Fix Enumerator#each_with_index with block
parents
905f46a1
d93a5c1a
master
mruby2-draft
removing-y-tab-c
revert-5391-throw
stable
3.1.0-rc
3.0.0
3.0.0-rc
3.0.0-preview
2.1.2
2.1.2-rc2
2.1.2-rc
2.1.1
2.1.1-rc2
2.1.1-rc
2.1.0
2.1.0-rc
2.0.1
2.0.0
1.4.1
1.4.0
1.3.0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
mrbgems/mruby-enumerator/mrblib/enumerator.rb
mrbgems/mruby-enumerator/mrblib/enumerator.rb
+2
-2
mrbgems/mruby-enumerator/test/enumerator.rb
mrbgems/mruby-enumerator/test/enumerator.rb
+7
-0
No files found.
mrbgems/mruby-enumerator/mrblib/enumerator.rb
View file @
898077a2
...
...
@@ -177,8 +177,8 @@ class Enumerator
#
# If no block is given, a new Enumerator is returned that includes the index.
#
def
each_with_index
with_index
def
each_with_index
(
&
block
)
with_index
(
0
,
&
block
)
end
##
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-enumerator/test/enumerator.rb
View file @
898077a2
...
...
@@ -65,6 +65,13 @@ assert 'Enumerator#with_index string offset' do
assert_raise
(
TypeError
){
@obj
.
to_enum
(
:foo
,
1
,
2
,
3
).
with_index
(
'1'
).
to_a
}
end
assert
'Enumerator#each_with_index'
do
assert_equal
([[
1
,
0
],[
2
,
1
],[
3
,
2
]],
@obj
.
to_enum
(
:foo
,
1
,
2
,
3
).
each_with_index
.
to_a
)
a
=
[]
@obj
.
to_enum
(
:foo
,
1
,
2
,
3
).
each_with_index
{
|*
i
|
a
<<
i
}
assert_equal
([[
1
,
0
],
[
2
,
1
],
[
3
,
2
]],
a
)
end
assert
'Enumerator#with_object'
do
obj
=
[
0
,
1
]
ret
=
(
1
..
10
).
each
.
with_object
(
obj
)
{
|
i
,
memo
|
...
...
This diff is collapsed.
Click to expand it.
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