What is time complexity of random indexing characters access in UTF-8 encoded string in Ruby?
When i run this code in command line interpreter:
s = "абв"
puts s.encoding.name
print s.bytes
puts
puts s.length
puts s[1]
it outputs:
UTF-8
[208, 176, 208, 177, 208, 178]
3
б
so i guess, when i try to get ith character from string, i have O(n) operations, where n is length of the string. Is it correct? I couldn't find some information about this in official documentation. In my opinion it's very important.