Search code examples
swiftstringprefixsuffix

Does String.prefix() work like String.suffix if using a right-to-left language?


Does String.prefix() work like String.suffix() if using a right-to-left language? That is instead of returning the left side of the string it returns the right side.


Solution

  • Nope, their functionality doesn't change. Right-to-left only matters when you're displaying any text to the user, for example in a UITextField. The Strings you access in your code are independent of the writing direction.