@@ -196,13 +196,15 @@ static VALUE copy_ary(RB_BLOCK_CALL_FUNC_ARGLIST(el, new_ary)) {
196196 return rb_ary_push (new_ary , el );
197197}
198198
199+ #ifndef RUBY_VERSION_IS_4_0
199200static VALUE array_spec_rb_iterate (VALUE self , VALUE ary ) {
200201 VALUE new_ary = rb_ary_new ();
201202
202203 rb_iterate (rb_each , ary , copy_ary , new_ary );
203204
204205 return new_ary ;
205206}
207+ #endif
206208
207209static VALUE array_spec_rb_block_call (VALUE self , VALUE ary ) {
208210 VALUE new_ary = rb_ary_new ();
@@ -216,6 +218,7 @@ static VALUE sub_pair(RB_BLOCK_CALL_FUNC_ARGLIST(el, holder)) {
216218 return rb_ary_push (holder , rb_ary_entry (el , 1 ));
217219}
218220
221+ #ifndef RUBY_VERSION_IS_4_0
219222static VALUE each_pair (VALUE obj ) {
220223 return rb_funcall (obj , rb_intern ("each_pair" ), 0 );
221224}
@@ -227,6 +230,7 @@ static VALUE array_spec_rb_iterate_each_pair(VALUE self, VALUE obj) {
227230
228231 return new_ary ;
229232}
233+ #endif
230234
231235static VALUE array_spec_rb_block_call_each_pair (VALUE self , VALUE obj ) {
232236 VALUE new_ary = rb_ary_new ();
@@ -241,10 +245,12 @@ static VALUE iter_yield(RB_BLOCK_CALL_FUNC_ARGLIST(el, ary)) {
241245 return Qnil ;
242246}
243247
248+ #ifndef RUBY_VERSION_IS_4_0
244249static VALUE array_spec_rb_iterate_then_yield (VALUE self , VALUE obj ) {
245250 rb_iterate (rb_each , obj , iter_yield , obj );
246251 return Qnil ;
247252}
253+ #endif
248254
249255static VALUE array_spec_rb_block_call_then_yield (VALUE self , VALUE obj ) {
250256 rb_block_call (obj , rb_intern ("each" ), 0 , 0 , iter_yield , obj );
@@ -308,9 +314,11 @@ void Init_array_spec(void) {
308314 rb_define_method (cls , "rb_ary_plus" , array_spec_rb_ary_plus , 2 );
309315 rb_define_method (cls , "rb_ary_unshift" , array_spec_rb_ary_unshift , 2 );
310316 rb_define_method (cls , "rb_assoc_new" , array_spec_rb_assoc_new , 2 );
317+ #ifndef RUBY_VERSION_IS_4_0
311318 rb_define_method (cls , "rb_iterate" , array_spec_rb_iterate , 1 );
312319 rb_define_method (cls , "rb_iterate_each_pair" , array_spec_rb_iterate_each_pair , 1 );
313320 rb_define_method (cls , "rb_iterate_then_yield" , array_spec_rb_iterate_then_yield , 1 );
321+ #endif
314322 rb_define_method (cls , "rb_block_call" , array_spec_rb_block_call , 1 );
315323 rb_define_method (cls , "rb_block_call_each_pair" , array_spec_rb_block_call_each_pair , 1 );
316324 rb_define_method (cls , "rb_block_call_then_yield" , array_spec_rb_block_call_then_yield , 1 );
0 commit comments