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
88604e39
Commit
88604e39
authored
Nov 12, 2016
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hash#[] to call Hash#default
parent
feb9b3de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
src/hash.c
src/hash.c
+11
-10
No files found.
src/hash.c
View file @
88604e39
...
...
@@ -173,10 +173,8 @@ mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key)
/* not found */
if
(
MRB_RHASH_DEFAULT_P
(
hash
))
{
if
(
MRB_RHASH_PROCDEFAULT_P
(
hash
))
{
return
mrb_funcall
(
mrb
,
RHASH_PROCDEFAULT
(
hash
),
"call"
,
2
,
hash
,
key
);
}
return
RHASH_IFNONE
(
hash
);
/* xxx mrb_funcall_tailcall(mrb, hash, "default", 1, key); */
return
mrb_funcall
(
mrb
,
hash
,
"default"
,
1
,
key
);
}
return
mrb_nil_value
();
}
...
...
@@ -385,6 +383,7 @@ mrb_hash_default(mrb_state *mrb, mrb_value hash)
mrb_bool
given
;
mrb_get_args
(
mrb
,
"|o?"
,
&
key
,
&
given
);
if
(
MRB_RHASH_DEFAULT_P
(
hash
))
{
if
(
MRB_RHASH_PROCDEFAULT_P
(
hash
))
{
if
(
!
given
)
return
mrb_nil_value
();
return
mrb_funcall
(
mrb
,
RHASH_PROCDEFAULT
(
hash
),
"call"
,
2
,
hash
,
key
);
...
...
@@ -392,6 +391,8 @@ mrb_hash_default(mrb_state *mrb, mrb_value hash)
else
{
return
RHASH_IFNONE
(
hash
);
}
}
return
mrb_nil_value
();
}
/* 15.2.13.4.6 */
...
...
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