diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-04 03:34:55 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-04 03:34:55 +0000 |
commit | f1fb989f1a17c63af1062ea402ed50f0d6cb4efa (patch) | |
tree | 8df231ea81ad5df2a408c9a5a431421f42516ea9 /enumerator.c | |
parent | 53d3fe0643c591a9083e22ccea62e49f451fd450 (diff) | |
download | ruby-f1fb989f1a17c63af1062ea402ed50f0d6cb4efa.tar.gz |
enumerator.c: make arith_seq_first support nil begin
* enumerator.c: (arith_seq_first): support nil begin.
* test/ruby/test_arithmetic_sequence.rb (test_first): add assertions for
beginless and endless arithmetic sequences.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r-- | enumerator.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/enumerator.c b/enumerator.c index 37f8e6bf21..cfc6a5dd98 100644 --- a/enumerator.c +++ b/enumerator.c @@ -3029,6 +3029,9 @@ arith_seq_first(int argc, VALUE *argv, VALUE self) e = arith_seq_end(self); s = arith_seq_step(self); if (argc == 0) { + if (NIL_P(b)) { + return Qnil; + } if (!NIL_P(e)) { VALUE zero = INT2FIX(0); int r = rb_cmpint(rb_num_coerce_cmp(s, zero, idCmp), s, zero); |