diff options
author | manga_osyo <[email protected]> | 2019-04-30 23:18:44 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2019-05-01 00:03:30 +0900 |
commit | 4e88e8692844a2a317bc19481f0f2601b6f00955 (patch) | |
tree | 07e66ab1a53b2f881475dcfa9659c0b61d642658 /range.c | |
parent | 0eedec68673fa74960dec80b26659263ec3b6a9a (diff) |
Add exception support in `Range#first`.
Closes: https://github.com/ruby/ruby/pull/2163
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -1012,6 +1012,9 @@ range_first(int argc, VALUE *argv, VALUE range) { VALUE n, ary[2]; + if (NIL_P(RANGE_BEG(range))) { + rb_raise(rb_eRangeError, "cannot get the first element of beginless range"); + } if (argc == 0) return RANGE_BEG(range); rb_scan_args(argc, argv, "1", &n); |