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
0d055559
Commit
0d055559
authored
Aug 22, 2015
by
INOUE Yasuyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use #nil? instead of == nil.
parent
71f2975a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
21 deletions
+21
-21
mrbgems/mruby-array-ext/mrblib/array.rb
mrbgems/mruby-array-ext/mrblib/array.rb
+12
-12
mrbgems/mruby-enum-ext/mrblib/enum.rb
mrbgems/mruby-enum-ext/mrblib/enum.rb
+3
-3
mrbgems/mruby-string-ext/mrblib/string.rb
mrbgems/mruby-string-ext/mrblib/string.rb
+6
-6
No files found.
mrbgems/mruby-array-ext/mrblib/array.rb
View file @
0d055559
...
...
@@ -217,7 +217,7 @@ class Array
# [ "a", "b", "c" ].compact! #=> nil
#
def
compact!
result
=
self
.
select
{
|
e
|
e
!=
nil
}
result
=
self
.
select
{
|
e
|
!
e
.
nil?
}
if
result
.
size
==
self
.
size
nil
else
...
...
@@ -262,7 +262,7 @@ class Array
#
def
fetch
(
n
=
nil
,
ifnone
=
NONE
,
&
block
)
warn
"block supersedes default value argument"
if
n
!=
nil
&&
ifnone
!=
NONE
&&
block
warn
"block supersedes default value argument"
if
!
n
.
nil?
&&
ifnone
!=
NONE
&&
block
idx
=
n
if
idx
<
0
...
...
@@ -312,51 +312,51 @@ class Array
#
def
fill
(
arg0
=
nil
,
arg1
=
nil
,
arg2
=
nil
,
&
block
)
if
arg0
==
nil
&&
arg1
==
nil
&&
arg2
==
nil
&&
!
block
if
arg0
.
nil?
&&
arg1
.
nil?
&&
arg2
.
nil?
&&
!
block
raise
ArgumentError
,
"wrong number of arguments (0 for 1..3)"
end
beg
=
len
=
0
ary
=
[]
if
block
if
arg0
==
nil
&&
arg1
==
nil
&&
arg2
==
nil
if
arg0
.
nil?
&&
arg1
.
nil?
&&
arg2
.
nil?
# ary.fill { |index| block } -> ary
beg
=
0
len
=
self
.
size
elsif
arg0
!=
nil
&&
arg0
.
kind_of?
(
Range
)
elsif
!
arg0
.
nil?
&&
arg0
.
kind_of?
(
Range
)
# ary.fill(range) { |index| block } -> ary
beg
=
arg0
.
begin
beg
+=
self
.
size
if
beg
<
0
len
=
arg0
.
end
len
+=
self
.
size
if
len
<
0
len
+=
1
unless
arg0
.
exclude_end?
elsif
arg0
!=
nil
elsif
!
arg0
.
nil?
# ary.fill(start [, length] ) { |index| block } -> ary
beg
=
arg0
beg
+=
self
.
size
if
beg
<
0
if
arg1
==
nil
if
arg1
.
nil?
len
=
self
.
size
else
len
=
arg0
+
arg1
end
end
else
if
arg0
!=
nil
&&
arg1
==
nil
&&
arg2
==
nil
if
!
arg0
.
nil?
&&
arg1
.
nil?
&&
arg2
.
nil?
# ary.fill(obj) -> ary
beg
=
0
len
=
self
.
size
elsif
arg0
!=
nil
&&
arg1
!=
nil
&&
arg1
.
kind_of?
(
Range
)
elsif
!
arg0
.
nil?
&&
!
arg1
.
nil?
&&
arg1
.
kind_of?
(
Range
)
# ary.fill(obj, range ) -> ary
beg
=
arg1
.
begin
beg
+=
self
.
size
if
beg
<
0
len
=
arg1
.
end
len
+=
self
.
size
if
len
<
0
len
+=
1
unless
arg1
.
exclude_end?
elsif
arg0
!=
nil
&&
arg1
!=
nil
elsif
!
arg0
.
nil?
&&
!
arg1
.
nil?
# ary.fill(obj, start [, length]) -> ary
beg
=
arg1
beg
+=
self
.
size
if
beg
<
0
if
arg2
==
nil
if
arg2
.
nil?
len
=
self
.
size
else
len
=
beg
+
arg2
...
...
@@ -582,7 +582,7 @@ class Array
elsif
v
==
true
satisfied
=
true
smaller
=
true
elsif
v
==
false
||
v
==
nil
elsif
v
==
false
||
v
.
nil?
smaller
=
false
end
if
smaller
...
...
mrbgems/mruby-enum-ext/mrblib/enum.rb
View file @
0d055559
...
...
@@ -515,7 +515,7 @@ module Enumerable
#
def
each_with_object
(
obj
=
nil
,
&
block
)
raise
ArgumentError
,
"wrong number of arguments (0 for 1)"
if
obj
==
nil
raise
ArgumentError
,
"wrong number of arguments (0 for 1)"
if
obj
.
nil?
return
to_enum
(
:each_with_object
,
obj
)
unless
block
...
...
@@ -574,10 +574,10 @@ module Enumerable
#
def
cycle
(
n
=
nil
,
&
block
)
return
to_enum
(
:cycle
,
n
)
if
!
block
&&
n
==
nil
return
to_enum
(
:cycle
,
n
)
if
!
block
&&
n
.
nil?
ary
=
[]
if
n
==
nil
if
n
.
nil?
self
.
each
do
|*
val
|
ary
.
push
val
block
.
call
(
*
val
)
...
...
mrbgems/mruby-string-ext/mrblib/string.rb
View file @
0d055559
...
...
@@ -164,9 +164,9 @@ class String
# string #=> "thsa sting"
#
def
slice!
(
arg1
,
arg2
=
nil
)
raise
"wrong number of arguments (for 1..2)"
if
arg1
==
nil
&&
arg2
==
nil
raise
"wrong number of arguments (for 1..2)"
if
arg1
.
nil?
&&
arg2
.
nil?
if
arg1
!=
nil
&&
arg2
!=
nil
if
!
arg1
.
nil?
&&
!
arg2
.
nil?
idx
=
arg1
idx
+=
self
.
size
if
arg1
<
0
if
idx
>=
0
&&
idx
<=
self
.
size
&&
arg2
>
0
...
...
@@ -196,8 +196,8 @@ class String
return
nil
end
end
unless
str
==
nil
||
str
==
""
if
arg1
!=
nil
&&
arg2
!=
nil
unless
str
.
nil?
||
str
==
""
if
!
arg1
.
nil?
&&
!
arg2
.
nil?
idx
=
arg1
>=
0
?
arg1
:
self
.
size
+
arg1
str2
=
self
[
0
...
idx
]
+
self
[
idx
+
arg2
..-
1
].
to_s
else
...
...
@@ -207,13 +207,13 @@ class String
str2
=
self
[
0
...
idx
]
+
self
[
idx2
+
1
..-
1
].
to_s
elsif
arg1
.
kind_of?
(
String
)
idx
=
self
.
index
(
arg1
)
str2
=
self
[
0
...
idx
]
+
self
[
idx
+
arg1
.
size
..-
1
]
unless
idx
==
nil
str2
=
self
[
0
...
idx
]
+
self
[
idx
+
arg1
.
size
..-
1
]
unless
idx
.
nil?
else
idx
=
arg1
>=
0
?
arg1
:
self
.
size
+
arg1
str2
=
self
[
0
...
idx
]
+
self
[
idx
+
1
..-
1
].
to_s
end
end
self
.
replace
(
str2
)
unless
str2
==
nil
self
.
replace
(
str2
)
unless
str2
.
nil?
end
str
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