mirror of
https://github.com/godotengine/godot.git
synced 2025-02-17 00:01:03 +00:00
Merge pull request #86704 from AThousandShips/len_fix
[GDScript] Add `StringName` support to `@GDScript.len`
This commit is contained in:
commit
06bb9f28e7
@ -148,7 +148,7 @@
|
|||||||
<return type="int" />
|
<return type="int" />
|
||||||
<param index="0" name="var" type="Variant" />
|
<param index="0" name="var" type="Variant" />
|
||||||
<description>
|
<description>
|
||||||
Returns the length of the given Variant [param var]. The length can be the character count of a [String], the element count of any array type or the size of a [Dictionary]. For every other Variant type, a run-time error is generated and execution is stopped.
|
Returns the length of the given Variant [param var]. The length can be the character count of a [String] or [StringName], the element count of any array type, or the size of a [Dictionary]. For every other Variant type, a run-time error is generated and execution is stopped.
|
||||||
[codeblock]
|
[codeblock]
|
||||||
a = [1, 2, 3, 4]
|
a = [1, 2, 3, 4]
|
||||||
len(a) # Returns 4
|
len(a) # Returns 4
|
||||||
|
@ -470,7 +470,8 @@ struct GDScriptUtilityFunctionsDefinitions {
|
|||||||
static inline void len(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
|
static inline void len(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
|
||||||
VALIDATE_ARG_COUNT(1);
|
VALIDATE_ARG_COUNT(1);
|
||||||
switch (p_args[0]->get_type()) {
|
switch (p_args[0]->get_type()) {
|
||||||
case Variant::STRING: {
|
case Variant::STRING:
|
||||||
|
case Variant::STRING_NAME: {
|
||||||
String d = *p_args[0];
|
String d = *p_args[0];
|
||||||
*r_ret = d.length();
|
*r_ret = d.length();
|
||||||
} break;
|
} break;
|
||||||
|
Loading…
Reference in New Issue
Block a user