Hopefully this is not a repeat; could not find references to this issue in a quick search.
In mata (Stata 14.2), when I index a string scalar, I get the following:
It seems like s[1] is just an alias for s. I was expecting to get the byte at position 1. Is this the intended behaviour? If so, why?
if 2 is invalid subscript as per the error message above, what is the range of valid subscripts in this case?
How do I get the byte at a specific index (other than using substr)?
Thanks,
/salah
In mata (Stata 14.2), when I index a string scalar, I get the following:
. mata: s = "hello"; s[1]
hello
. mata: s = "hello"; s[2]
<istmt>: 3301 subscript invalid
r(3301);
hello
. mata: s = "hello"; s[2]
<istmt>: 3301 subscript invalid
r(3301);
if 2 is invalid subscript as per the error message above, what is the range of valid subscripts in this case?
How do I get the byte at a specific index (other than using substr)?
Thanks,
/salah
Comment