Ask A Question

Notifications

You’re not receiving notifications from this thread.

Base62 Encoding Short Codes Discussion

Hi Chris,
why the local variable result is treated as frozen?
Here is the error:
Error:
ShortCodeTest#test_encode_10:
FrozenError: can't modify frozen String: ""
app/models/short_code.rb:20:in prepend'
app/models/short_code.rb:20:in
encode'
test/models/short_code_test.rb:15:in `block in class:ShortCodeTest'

Reply

Sounds like you have a bug somewhere. Have you compared your code to the repository?

Reply

the code is the same. If I initialize the local variable result with:
result =+"" or result = String.new
no errors, tests passing

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 77,200+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2023 GoRails, LLC. All rights reserved.