diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-09 14:36:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-09 14:36:02 +0000 |
commit | 10117968d4d8e234f0a7f56daf2e7682f8024072 (patch) | |
tree | e2de020af164479558f8d89c0a2aac3dbc552397 /enum.c | |
parent | 819bb50e4d737a83e97bcf6e89684aae8c81fb5d (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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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; } |