The elements of strings have type byte and may be accessed using the
usual indexing operations.
How can I get element of string as char ?
“some”[1] -> “o”
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The simplest solution is to convert it to an array of runes :
Note that when you iterate on a string, you don’t need the conversion. See this example from Effective Go :
This prints