Skip to content

Commit a29c83d

Browse files
committed
Rename method parameter to callable in many Array methods
1 parent 7ed0b61 commit a29c83d

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

core/variant/variant_call.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ static void _register_variant_builtin_methods_array() {
26952695
bind_method(Array, find, sarray("what", "from"), varray(0));
26962696
bind_method(Array, find_custom, sarray("method", "from"), varray(0));
26972697
bind_method(Array, rfind, sarray("what", "from"), varray(-1));
2698-
bind_method(Array, rfind_custom, sarray("method", "from"), varray(-1));
2698+
bind_method(Array, rfind_custom, sarray("callable", "from"), varray(-1));
26992699
bind_method(Array, count, sarray("value"), varray());
27002700
bind_method(Array, has, sarray("value"), varray());
27012701
bind_method(Array, pop_back, sarray(), varray());
@@ -2710,11 +2710,11 @@ static void _register_variant_builtin_methods_array() {
27102710
bind_method(Array, duplicate, sarray("deep"), varray(false));
27112711
bind_method(Array, duplicate_deep, sarray("deep_subresources_mode"), varray(RESOURCE_DEEP_DUPLICATE_INTERNAL));
27122712
bind_method(Array, slice, sarray("begin", "end", "step", "deep"), varray(INT_MAX, 1, false));
2713-
bind_method(Array, filter, sarray("method"), varray());
2714-
bind_method(Array, map, sarray("method"), varray());
2715-
bind_method(Array, reduce, sarray("method", "accum"), varray(Variant()));
2716-
bind_method(Array, any, sarray("method"), varray());
2717-
bind_method(Array, all, sarray("method"), varray());
2713+
bind_method(Array, filter, sarray("callable"), varray());
2714+
bind_method(Array, map, sarray("callable"), varray());
2715+
bind_method(Array, reduce, sarray("callable", "accum"), varray(Variant()));
2716+
bind_method(Array, any, sarray("callable"), varray());
2717+
bind_method(Array, all, sarray("callable"), varray());
27182718
bind_method(Array, max, sarray(), varray());
27192719
bind_method(Array, min, sarray(), varray());
27202720
bind_method(Array, is_typed, sarray(), varray());

doc/classes/Array.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@
165165
<methods>
166166
<method name="all" qualifiers="const">
167167
<return type="bool" />
168-
<param index="0" name="method" type="Callable" />
168+
<param index="0" name="callable" type="Callable" />
169169
<description>
170170
Calls the given [Callable] on each element in the array and returns [code]true[/code] if the [Callable] returns [code]true[/code] for [i]all[/i] elements in the array. If the [Callable] returns [code]false[/code] for one array element or more, this method returns [code]false[/code].
171-
The [param method] should take one [Variant] parameter (the current array element) and return a [bool].
171+
The [param callable] should take one [Variant] parameter (the current array element) and return a [bool].
172172
[codeblocks]
173173
[gdscript]
174174
func greater_than_5(number):
@@ -212,10 +212,10 @@
212212
</method>
213213
<method name="any" qualifiers="const">
214214
<return type="bool" />
215-
<param index="0" name="method" type="Callable" />
215+
<param index="0" name="callable" type="Callable" />
216216
<description>
217217
Calls the given [Callable] on each element in the array and returns [code]true[/code] if the [Callable] returns [code]true[/code] for [i]one or more[/i] elements in the array. If the [Callable] returns [code]false[/code] for all elements in the array, this method returns [code]false[/code].
218-
The [param method] should take one [Variant] parameter (the current array element) and return a [bool].
218+
The [param callable] should take one [Variant] parameter (the current array element) and return a [bool].
219219
[codeblock]
220220
func greater_than_5(number):
221221
return number &gt; 5
@@ -386,10 +386,10 @@
386386
</method>
387387
<method name="filter" qualifiers="const">
388388
<return type="Array" />
389-
<param index="0" name="method" type="Callable" />
389+
<param index="0" name="callable" type="Callable" />
390390
<description>
391391
Calls the given [Callable] on each element in the array and returns a new, filtered [Array].
392-
The [param method] receives one of the array elements as an argument, and should return [code]true[/code] to add the element to the filtered array, or [code]false[/code] to exclude it.
392+
The [param callable] receives one of the array elements as an argument, and should return [code]true[/code] to add the element to the filtered array, or [code]false[/code] to exclude it.
393393
[codeblock]
394394
func is_even(number):
395395
return number % 2 == 0
@@ -415,12 +415,12 @@
415415
</method>
416416
<method name="find_custom" qualifiers="const">
417417
<return type="int" />
418-
<param index="0" name="method" type="Callable" />
418+
<param index="0" name="callable" type="Callable" />
419419
<param index="1" name="from" type="int" default="0" />
420420
<description>
421-
Returns the index of the [b]first[/b] element in the array that causes [param method] to return [code]true[/code], or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the end of the array.
422-
[param method] is a callable that takes an element of the array, and returns a [bool].
423-
[b]Note:[/b] If you just want to know whether the array contains [i]anything[/i] that satisfies [param method], use [method any].
421+
Returns the index of the [b]first[/b] element in the array that causes [param callable] to return [code]true[/code], or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the end of the array.
422+
[param callable] takes an element of the array and returns a [bool].
423+
[b]Note:[/b] If you just want to know whether the array contains [i]anything[/i] that satisfies [param callable], use [method any].
424424
[codeblocks]
425425
[gdscript]
426426
func is_even(number):
@@ -551,10 +551,10 @@
551551
</method>
552552
<method name="map" qualifiers="const">
553553
<return type="Array" />
554-
<param index="0" name="method" type="Callable" />
554+
<param index="0" name="callable" type="Callable" />
555555
<description>
556-
Calls the given [Callable] for each element in the array and returns a new array filled with values returned by the [param method].
557-
The [param method] should take one [Variant] parameter (the current array element) and can return any [Variant].
556+
Calls the given [Callable] for each element in the array and returns a new array filled with values returned by the [param callable].
557+
The [param callable] should take one [Variant] parameter (the current array element) and can return any [Variant].
558558
[codeblock]
559559
func double(number):
560560
return number * 2
@@ -636,11 +636,11 @@
636636
</method>
637637
<method name="reduce" qualifiers="const">
638638
<return type="Variant" />
639-
<param index="0" name="method" type="Callable" />
639+
<param index="0" name="callable" type="Callable" />
640640
<param index="1" name="accum" type="Variant" default="null" />
641641
<description>
642642
Calls the given [Callable] for each element in array, accumulates the result in [param accum], then returns it.
643-
The [param method] takes two arguments: the current value of [param accum] and the current array element. If [param accum] is [code]null[/code] (as by default), the iteration will start from the second element, with the first one used as initial value of [param accum].
643+
The [param callable] takes two arguments: the current value of [param accum] and the current array element. If [param accum] is [code]null[/code] (as by default), the iteration will start from the second element, with the first one used as initial value of [param accum].
644644
[codeblock]
645645
func sum(accum, number):
646646
return accum + number
@@ -711,10 +711,10 @@
711711
</method>
712712
<method name="rfind_custom" qualifiers="const">
713713
<return type="int" />
714-
<param index="0" name="method" type="Callable" />
714+
<param index="0" name="callable" type="Callable" />
715715
<param index="1" name="from" type="int" default="-1" />
716716
<description>
717-
Returns the index of the [b]last[/b] element of the array that causes [param method] to return [code]true[/code], or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the beginning of the array. This method is the reverse of [method find_custom].
717+
Returns the index of the [b]last[/b] element of the array that causes [param callable] to return [code]true[/code], or [code]-1[/code] if there are none. The search's start can be specified with [param from], continuing to the beginning of the array. This method is the reverse of [method find_custom].
718718
</description>
719719
</method>
720720
<method name="set">

0 commit comments

Comments
 (0)