summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-09 14:36:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-09 14:36:02 +0000
commit10117968d4d8e234f0a7f56daf2e7682f8024072 (patch)
treee2de020af164479558f8d89c0a2aac3dbc552397 /enum.c
parent819bb50e4d737a83e97bcf6e89684aae8c81fb5d (diff)
* enum.c (enum_inject): default the result value to Qundef to use
first element as initial value if not given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/enum.c b/enum.c
index a61a5c16a3..ca52b6f566 100644
--- a/enum.c
+++ b/enum.c
@@ -305,8 +305,10 @@ enum_inject(argc, argv, obj)
{
VALUE memo = Qundef;
- rb_scan_args(argc, argv, "01", &memo);
+ if (rb_scan_args(argc, argv, "01", &memo) == 0)
+ memo = Qundef;
rb_iterate(rb_each, obj, inject_i, (VALUE)&memo);
+ if (memo == Qundef) return Qnil;
return memo;
}