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
7ed164ba
Unverified
Commit
7ed164ba
authored
Jun 01, 2018
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Jun 01, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4031 from i110/i110/hash_default
let Hash#merge keep ifnone value
parents
b64ce178
4a2b055c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
2 deletions
+1
-2
mrblib/hash.rb
mrblib/hash.rb
+1
-2
No files found.
mrblib/hash.rb
View file @
7ed164ba
...
@@ -179,10 +179,9 @@ class Hash
...
@@ -179,10 +179,9 @@ class Hash
#
#
# ISO 15.2.13.4.22
# ISO 15.2.13.4.22
def
merge
(
other
,
&
block
)
def
merge
(
other
,
&
block
)
h
=
{}
raise
TypeError
,
"can't convert argument into Hash"
unless
other
.
respond_to?
(
:to_hash
)
raise
TypeError
,
"can't convert argument into Hash"
unless
other
.
respond_to?
(
:to_hash
)
other
=
other
.
to_hash
other
=
other
.
to_hash
self
.
each_key
{
|
k
|
h
[
k
]
=
self
[
k
]}
h
=
self
.
dup
if
block
if
block
other
.
each_key
{
|
k
|
other
.
each_key
{
|
k
|
h
[
k
]
=
(
self
.
has_key?
(
k
))?
block
.
call
(
k
,
self
[
k
],
other
[
k
]):
other
[
k
]
h
[
k
]
=
(
self
.
has_key?
(
k
))?
block
.
call
(
k
,
self
[
k
],
other
[
k
]):
other
[
k
]
...
...
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