summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-02 17:39:57 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-02 17:39:57 +0000
commit9317700a5dc77053b84180456fa0ae10a3d33218 (patch)
tree127ad25068a7550f404dd9ffb4816206e644b066 /enumerator.c
parent2c875a0fde1c0b3190b56b7637624ea70b95a434 (diff)
* eval.c (splat_value): use "to_splat" instead of "to_ary" to
prepare splat values as an array. * array.c (Init_Array): define to_splat. * range.c (range_to_splat): new method. * enumerator.c (enumerator_to_splat): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/enumerator.c b/enumerator.c
index ec348ded37..727990f652 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -359,6 +359,19 @@ enumerator_with_index(VALUE obj)
enumerator_with_index_i, (VALUE)&memo);
}
+/*
+ * call-seq:
+ * e.to_splat => array
+ *
+ * Convert this enumerator object to an array to splat.
+ */
+
+static VALUE
+enumerator_to_splat(VALUE range)
+{
+ return rb_convert_type(range, T_ARRAY, "Array", "to_a");
+}
+
void
Init_Enumerator(void)
{
@@ -378,6 +391,7 @@ Init_Enumerator(void)
rb_define_method(rb_cEnumerator, "initialize", enumerator_initialize, -1);
rb_define_method(rb_cEnumerator, "each", enumerator_each, 0);
rb_define_method(rb_cEnumerator, "with_index", enumerator_with_index, 0);
+ rb_define_method(rb_cEnumerator, "to_splat", enumerator_to_splat, 0);
sym_each = ID2SYM(rb_intern("each"));
sym_each_with_index = ID2SYM(rb_intern("each_with_index"));