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
85f0dd7d
Commit
85f0dd7d
authored
Aug 20, 2015
by
go.kikuta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enum.rb: refactor code (remove redundant code)
parent
931a7223
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
26 deletions
+6
-26
mrblib/enum.rb
mrblib/enum.rb
+6
-26
No files found.
mrblib/enum.rb
View file @
85f0dd7d
...
...
@@ -24,17 +24,9 @@ module Enumerable
# ISO 15.3.2.2.1
def
all?
(
&
block
)
if
block
self
.
each
{
|*
val
|
unless
block
.
call
(
*
val
)
return
false
end
}
self
.
each
{
|*
val
|
return
false
unless
block
.
call
(
*
val
)}
else
self
.
each
{
|*
val
|
unless
val
.
__svalue
return
false
end
}
self
.
each
{
|*
val
|
return
false
unless
val
.
__svalue
}
end
true
end
...
...
@@ -49,17 +41,9 @@ module Enumerable
# ISO 15.3.2.2.2
def
any?
(
&
block
)
if
block
self
.
each
{
|*
val
|
if
block
.
call
(
*
val
)
return
true
end
}
self
.
each
{
|*
val
|
return
true
if
block
.
call
(
*
val
)}
else
self
.
each
{
|*
val
|
if
val
.
__svalue
return
true
end
}
self
.
each
{
|*
val
|
return
true
if
val
.
__svalue
}
end
false
end
...
...
@@ -75,9 +59,7 @@ module Enumerable
return
to_enum
:collect
unless
block
ary
=
[]
self
.
each
{
|*
val
|
ary
.
push
(
block
.
call
(
*
val
))
}
self
.
each
{
|*
val
|
ary
.
push
(
block
.
call
(
*
val
))}
ary
end
...
...
@@ -183,9 +165,7 @@ module Enumerable
# ISO 15.3.2.2.10
def
include?
(
obj
)
self
.
each
{
|*
val
|
if
val
.
__svalue
==
obj
return
true
end
return
true
if
val
.
__svalue
==
obj
}
false
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