Hi
I have a set of strings(ASCII), that i want to assign to a string array(of
cap 128).
The position of the string in the array is decided by the ASCII value of
the first char of the string.
Like...

strArr := [128]string{}
strA := "A string"
strB := "B string"

strArr[65] = strA // since strA started with 'A' & ASCII('A') = 65
strArr[66] = strB // since strB started with 'B' & ASCII('B') = 66


There is one solution of using utf8.DecodeRuneInString, like ...

r, _ := utf8.DecodeRuneInString(strA)
strArr[r] = strA


*Is it possible to time optimise this solution?*

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANFuhy88vM44UQen58wjADSHrJV%2BuDY6J4rU8caumdkxwoucnA%40mail.gmail.com.

Reply via email to