String/Array Methods Discussion
The purpose of this issue is to discuss the current and future direction and implementations of methods in Ion. The current idea is that methods should be assigned based on the type that they return, which means that if a method returns a string, then it should be a string method, whereas if the method returns an array, then it should be an array method. Methods implemented are below:
String Var Methods
- $join(array[, pattern])
- Join an array into a string with an optional pattern
- Default pattern is a space
- $len(string)
- Returns the number of graphemes in the string
- Should this also support arrays? And if so, how?
- $len_chars(string)
- Returns the number of chars in the string
- Not implemented
- $len_bytes(string)
- Returns the number of bytes in the string
- $len_array(string)
- Possible method for getting length of arrays?
- $trim(string)
- Not Implemented
- Performs the trim method on the given variable
Array Var Methods
- @split(string[, pattern])
- Split a string with an optional pattern
- Default pattern is to split by whitespace characters
- Patterns should probably support regex, but currently don't
- @len(array)
- This method should probably be migrated as a string method