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
11524f6f
Commit
11524f6f
authored
Aug 20, 2015
by
go.kikuta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string.rb: refactor code (remove redundant code)
parent
cb870de2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
19 deletions
+7
-19
mrblib/string.rb
mrblib/string.rb
+7
-19
No files found.
mrblib/string.rb
View file @
11524f6f
...
...
@@ -80,12 +80,8 @@ class String
# ISO 15.2.10.5.19
def
gsub!
(
*
args
,
&
block
)
str
=
self
.
gsub
(
*
args
,
&
block
)
if
str
!=
self
self
.
replace
(
str
)
self
else
nil
end
return
nil
if
str
==
self
self
.
replace
(
str
)
end
##
...
...
@@ -129,12 +125,8 @@ class String
# ISO 15.2.10.5.37
def
sub!
(
*
args
,
&
block
)
str
=
self
.
sub
(
*
args
,
&
block
)
if
str
!=
self
self
.
replace
(
str
)
self
else
nil
end
return
nil
if
str
==
self
self
.
replace
(
str
)
end
##
...
...
@@ -165,20 +157,16 @@ class String
# Modify +self+ by replacing the content of +self+
# at the position +pos+ with +value+.
def
[]=
(
pos
,
value
)
if
pos
<
0
pos
+=
self
.
length
end
pos
+=
self
.
length
if
pos
<
0
b
=
self
[
0
,
pos
]
a
=
self
[
pos
+
1
..-
1
]
a
=
self
[
pos
+
1
..-
1
]
self
.
replace
([
b
,
value
,
a
].
join
(
''
))
end
##
# ISO 15.2.10.5.3
def
=~
(
re
)
if
re
.
respond_to?
:to_str
raise
TypeError
,
"type mismatch: String given"
end
raise
TypeError
,
"type mismatch: String given"
if
re
.
respond_to?
:to_str
re
=~
self
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