Monday, March 20, 2023
HomeGolangKind of string letter complication - Obtaining Assistance

Kind of string letter complication – Obtaining Assistance


Why a solitary letter in go is a string kind:

 myLetter:= "S".
fmt.Println( reflect.TypeOf( myLetter)).
//.
// string.

… yet letter extracted from the string as an table component its ending up being uint8:

 myString:= "String".
myLetter:= myString[0]
fmt.Println( reflect.TypeOf( myLetter)).
//.
// uint8.

… as well as when I make use of for-loop its int32 every one of the unexpected:

 myString:= "String".
for _, v:= array myString {
fmt.Println( reflect.TypeOf( v)).
//.
// int32 (x5).
}

This is soooo complicated me when I code, plus I require to create added transforming features whenever I do something string-manipulation-related.

What is the thinking behind this? Do you have any kind of techniques to enhance my operations?


RELATED ARTICLES

Most Popular

Recent Comments