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
0f774ff4
Unverified
Commit
0f774ff4
authored
Dec 01, 2016
by
ksss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support nil argument as no argument
parent
61ac564c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
mrbgems/mruby-enumerator/mrblib/enumerator.rb
mrbgems/mruby-enumerator/mrblib/enumerator.rb
+8
-2
No files found.
mrbgems/mruby-enumerator/mrblib/enumerator.rb
View file @
0f774ff4
...
...
@@ -153,9 +153,15 @@ class Enumerator
#
def
with_index
(
offset
=
0
)
return
to_enum
:with_index
,
offset
unless
block_given?
raise
TypeError
,
"no implicit conversion of
#{
offset
.
class
}
into Integer"
unless
offset
.
respond_to?
(
:to_int
)
offset
=
if
offset
.
nil?
0
elsif
offset
.
respond_to?
(
:to_int
)
offset
.
to_int
else
raise
TypeError
,
"no implicit conversion of
#{
offset
.
class
}
into Integer"
end
n
=
offset
.
to_int
-
1
n
=
offset
-
1
enumerator_block_call
do
|
i
|
n
+=
1
yield
[
i
,
n
]
...
...
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