summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'range.c')
-rw-r--r--range.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/range.c b/range.c
index a7f8e44b37..8d5bae8179 100644
--- a/range.c
+++ b/range.c
@@ -571,6 +571,19 @@ range_to_s(VALUE range)
/*
* call-seq:
+ * rng.to_splat => array
+ *
+ * Convert this range object to an array to splat.
+ */
+
+static VALUE
+range_to_splat(VALUE range)
+{
+ return rb_convert_type(range, T_ARRAY, "Array", "to_a");
+}
+
+/*
+ * call-seq:
* rng.inspect => string
*
* Convert this range object to a printable form (using
@@ -746,6 +759,7 @@ Init_Range(void)
rb_define_method(rb_cRange, "max", range_max, 0);
rb_define_method(rb_cRange, "to_s", range_to_s, 0);
rb_define_method(rb_cRange, "inspect", range_inspect, 0);
+ rb_define_method(rb_cRange, "to_splat", range_to_splat, 0);
rb_define_method(rb_cRange, "exclude_end?", range_exclude_end_p, 0);