String at


Decided to upgrade to 0.33.0, but getting undefined method ‘at’ for String

x = "hello"
s =


Check the Changelog

String#at was deprecated in version 0.29.0 and eventually removed in 0.33.0. You can use x[2] instead.

Out of curiosity: didn’t you see this deprecation warning? Or maybe you upgraded your code from a really old Crystal version right to 0.33.0?

I am/was using Crystal 0.30 since last year. I did not have any problems using String at, no deprecation warnings at all, just this message.

 123 | t <<
Error: undefined method 'at' for String

My installation method is a bit different, I downloaded the 64 bits deb and manually installed it.
I did not use sudo apt-get install crystal.

But I changed the code, and I am running all my specs.

1 Like