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
31b2980a
Commit
31b2980a
authored
Mar 18, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1880 from ksss/enum-each_with_index
Enumrable#each_with_index return Enumerator if non block given
parents
555c1876
9abe4135
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
mrbgems/mruby-enumerator/test/enumerator.rb
mrbgems/mruby-enumerator/test/enumerator.rb
+4
-0
mrblib/enum.rb
mrblib/enum.rb
+2
-0
No files found.
mrbgems/mruby-enumerator/test/enumerator.rb
View file @
31b2980a
...
...
@@ -438,6 +438,10 @@ assert 'Integral#times' do
assert_equal
[
0
,
1
,
2
],
c
end
assert
'Enumerable#each_with_index'
do
assert_equal
[[
'a'
,
0
],[
'b'
,
1
],[
'c'
,
2
]],
[
'a'
,
'b'
,
'c'
].
each_with_index
.
to_a
end
assert
'Enumerable#map'
do
a
=
[
1
,
2
,
3
]
b
=
a
.
map
...
...
mrblib/enum.rb
View file @
31b2980a
...
...
@@ -108,6 +108,8 @@ module Enumerable
#
# ISO 15.3.2.2.5
def
each_with_index
(
&
block
)
return
to_enum
:each_with_index
unless
block_given?
i
=
0
self
.
each
{
|*
val
|
block
.
call
(
val
.
__svalue
,
i
)
...
...
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