07-18-2023, 06:54 PM
How can I get the nth character of a string? I tried bracket(`[]`) accessor with no luck.
var string = "Hello, world!"
var firstChar = string[0] // Throws error
> ERROR: 'subscript' is unavailable: cannot subscript String with an Int, see the documentation comment for discussion
var string = "Hello, world!"
var firstChar = string[0] // Throws error
> ERROR: 'subscript' is unavailable: cannot subscript String with an Int, see the documentation comment for discussion