summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authorNuzair46 <nuzer501@gmail.com>2026-03-17 18:06:51 +0900
committerNobuyoshi Nakada <nobu.nakada@gmail.com>2026-03-17 23:50:15 +0900
commit3903419deeece358c31b3da9afc4a0250139a5e4 (patch)
treeb6cd1031960b516d890095080195e033223d98ac /enumerator.c
parentdc1777d01770ab62ec99ff6fa4cf622098f44968 (diff)
[Feature #21520] Rename Enumerator::Lazy#tee to #tap_each
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/enumerator.c b/enumerator.c
index 42c11a08f8..81b71bd8b4 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -2772,7 +2772,7 @@ lazy_with_index(int argc, VALUE *argv, VALUE obj)
}
static struct MEMO *
-lazy_tee_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
+lazy_tap_each_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
{
struct proc_entry *entry = proc_entry_ptr(proc_entry);
@@ -2781,13 +2781,13 @@ lazy_tee_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_inde
return result;
}
-static const lazyenum_funcs lazy_tee_funcs = {
- lazy_tee_proc, 0,
+static const lazyenum_funcs lazy_tap_each_funcs = {
+ lazy_tap_each_proc, 0,
};
/*
* call-seq:
- * lazy.tee { |item| ... } -> lazy_enumerator
+ * lazy.tap_each { |item| ... } -> lazy_enumerator
*
* Passes each element through to the block for side effects only,
* without modifying the element or affecting the enumeration.
@@ -2797,7 +2797,7 @@ static const lazyenum_funcs lazy_tee_funcs = {
* without breaking laziness or misusing +map+.
*
* (1..).lazy
- * .tee { |x| puts "got #{x}" }
+ * .tap_each { |x| puts "got #{x}" }
* .select(&:even?)
* .first(3)
* # prints: got 1, got 2, ..., got 6
@@ -2807,14 +2807,14 @@ static const lazyenum_funcs lazy_tee_funcs = {
*/
static VALUE
-lazy_tee(VALUE obj)
+lazy_tap_each(VALUE obj)
{
if (!rb_block_given_p())
{
- rb_raise(rb_eArgError, "tried to call lazy tee without a block");
+ rb_raise(rb_eArgError, "tried to call lazy tap_each without a block");
}
- return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_tee_funcs);
+ return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_tap_each_funcs);
}
#if 0 /* for RDoc */
@@ -4692,7 +4692,7 @@ InitVM_Enumerator(void)
rb_define_method(rb_cLazy, "uniq", lazy_uniq, 0);
rb_define_method(rb_cLazy, "compact", lazy_compact, 0);
rb_define_method(rb_cLazy, "with_index", lazy_with_index, -1);
- rb_define_method(rb_cLazy, "tee", lazy_tee, 0);
+ rb_define_method(rb_cLazy, "tap_each", lazy_tap_each, 0);
lazy_use_super_method = rb_hash_new_with_size(18);
rb_hash_aset(lazy_use_super_method, sym("map"), sym("_enumerable_map"));