Godot: Double methods for case sensitive functions.

Created on 5 Jun 2019  路  2Comments  路  Source: godotengine/godot

Is there a reason that for some classes you have the same method twice like:
Screenshot_3
Screenshot_1

int find( String what, int from=0 )
Finds the first occurrence of a substring. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.

And:

int findn( String what, int from=0 )
Finds the first occurrence of a substring, ignoring case. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.

While you could just have:

int find( String what, int from=0, bool case_sensitive=true )
Finds the first occurrence of a substring. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index and whether the search will be case sensitive can be passed.

Or at least document that find() is case sensitive:

int find( String what, int from=0 )
Finds the first occurrence of a substring. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. find() is case sensitive, if you want to ignore case then reference to findn()

Since from what i understand by looking at the code, it could be hard to merge these classes since they are also used internally by the engine.

archived discussion enhancement core gdscript

Most helpful comment

Probably a candidate for #16863

All 2 comments

Probably a candidate for #16863

int find( String what, int from=0, bool case_sensitive=true )

This is already the case for some string methods in C#: https://github.com/godotengine/godot/blob/master/modules/mono/glue/Managed/Files/StringExtensions.cs#L178

Was this page helpful?
0 / 5 - 0 ratings