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
17206087
Commit
17206087
authored
Jun 04, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Hash#to_h; ref #2348
parent
8a9e2066
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
mrbgems/mruby-hash-ext/mrblib/hash.rb
mrbgems/mruby-hash-ext/mrblib/hash.rb
+11
-0
mrbgems/mruby-hash-ext/test/hash.rb
mrbgems/mruby-hash-ext/test/hash.rb
+6
-0
No files found.
mrbgems/mruby-hash-ext/mrblib/hash.rb
View file @
17206087
...
...
@@ -182,4 +182,15 @@ class Hash
end
nil
end
##
# call-seq:
# hsh.to_h -> hsh or new_hash
#
# Returns +self+. If called on a subclass of Hash, converts
# the receiver to a Hash object.
#
def
to_h
self
end
end
mrbgems/mruby-hash-ext/test/hash.rb
View file @
17206087
...
...
@@ -115,3 +115,9 @@ assert("Hash#key") do
assert_nil
h
.
key
(
'nil'
)
assert_equal
'nil'
,
h
.
key
(
nil
)
end
assert
(
"Hash#to_h"
)
do
h
=
{
"a"
=>
100
,
"b"
=>
200
}
assert_equal
Hash
,
h
.
to_h
.
class
assert_equal
h
,
h
.
to_h
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