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
cb3ee2d0
Unverified
Commit
cb3ee2d0
authored
Jun 23, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Jun 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4526 from shuujii/refine-Hash-rehash-example
Refine `Hash#rehash` example [ci skip]
parents
af9637e5
28de6b0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
src/hash.c
src/hash.c
+15
-4
No files found.
src/hash.c
View file @
cb3ee2d0
...
...
@@ -1378,10 +1378,21 @@ mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2)
* values of key objects have changed since they were inserted, this
* method will reindex <i>hsh</i>.
*
* h = {"AAA" => "b"}
* h.keys[0].chop!
* h.rehash #=> {"AA"=>"b"}
* h["AA"] #=> "b"
* keys = (1..17).map{|n| [n]}
* k = keys[0]
* h = {}
* keys.each{|key| h[key] = key[0]}
* h #=> { [1]=> 1, [2]=> 2, [3]=> 3, [4]=> 4, [5]=> 5, [6]=> 6, [7]=> 7,
* [8]=> 8, [9]=> 9,[10]=>10,[11]=>11,[12]=>12,[13]=>13,[14]=>14,
* [15]=>15,[16]=>16,[17]=>17}
* h[k] #=> 1
* k[0] = keys.size + 1
* h #=> {[18]=> 1, [2]=> 2, [3]=> 3, [4]=> 4, [5]=> 5, [6]=> 6, [7]=> 7,
* [8]=> 8, [9]=> 9,[10]=>10,[11]=>11,[12]=>12,[13]=>13,[14]=>14,
* [15]=>15,[16]=>16,[17]=>17}
* h[k] #=> nil
* h.rehash
* h[k] #=> 1
*/
static
mrb_value
mrb_hash_rehash
(
mrb_state
*
mrb
,
mrb_value
self
)
...
...
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