T
Trylon
Guest
Was given the impression that string_char_at would return "" if index is does not point to a letter.
Description
You can use this function to return a specific character at a specific position within a string, with the index starting at 1 for the first character. If no character is found or the string is shorter than the value given to index, an empty string "" is returned.
But it seems that values less than 1 simply return the first character in the string:
left_char = string_char_at("acyclic",1);
//left_char is "a"
left_char = string_char_at("acyclic",0);
//left_char is "a"
left_char = string_char_at("acyclic",-1);
//left_char is "a"
left_char = string_char_at("acyclic",-2);
//left_char is "a"
If this the expected behavior perhaps it might be noted in the manual as it seems a bit unintuitive.
Description
You can use this function to return a specific character at a specific position within a string, with the index starting at 1 for the first character. If no character is found or the string is shorter than the value given to index, an empty string "" is returned.
But it seems that values less than 1 simply return the first character in the string:
left_char = string_char_at("acyclic",1);
//left_char is "a"
left_char = string_char_at("acyclic",0);
//left_char is "a"
left_char = string_char_at("acyclic",-1);
//left_char is "a"
left_char = string_char_at("acyclic",-2);
//left_char is "a"
If this the expected behavior perhaps it might be noted in the manual as it seems a bit unintuitive.