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
5f16c417
Commit
5f16c417
authored
Sep 18, 2014
by
INOUE Yasuyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy documentation comment from CRuby
parent
d30aadf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
mrbgems/mruby-hash-ext/mrblib/hash.rb
mrbgems/mruby-hash-ext/mrblib/hash.rb
+20
-0
No files found.
mrbgems/mruby-hash-ext/mrblib/hash.rb
View file @
5f16c417
...
...
@@ -3,6 +3,26 @@ class Hash
# ISO does not define Hash#each_pair, so each_pair is defined in gem.
alias
each_pair
each
##
# call-seq:
# Hash[ key, value, ... ] -> new_hash
# Hash[ [ [key, value], ... ] ] -> new_hash
# Hash[ object ] -> new_hash
#
# Creates a new hash populated with the given objects.
#
# Similar to the literal <code>{ _key_ => _value_, ... }</code>. In the first
# form, keys and values occur in pairs, so there must be an even number of
# arguments.
#
# The second and third form take a single argument which is either an array
# of key-value pairs or an object convertible to a hash.
#
# Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200}
# Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200}
# Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200}
#
def
self
.
[]
(
*
object
)
o
=
object
[
0
]
if
o
.
respond_to?
(
:to_hash
)
...
...
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