Created
June 7, 2024 22:01
-
-
Save mikebaldry/66fe37006e9bd3d574f4451b1082d57e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ./ruby test.rb | |
test.rb:9: warning: 'sub!' called on a string that could, in the future be frozen. string created at test.rb:4 | |
test.rb:14: warning: '[]=' called on a string that could, in the future be frozen. string created at test.rb:4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: warn | |
from_a_dynamic = "Hello, #{(1..100).to_a.sample}!" | |
from_a_literal = "Hello, world!" | |
dup_from_a_literal = from_a_literal.dup | |
dup_from_a_dynamic = from_a_dynamic.dup | |
from_a_literal.sub!(/world/, "Ruby!") | |
dup_from_a_literal.sub!(/world/, "Ruby!") | |
from_a_dynamic.sub!(/world/, "Ruby!") | |
dup_from_a_dynamic.sub!(/world/, "Ruby!") | |
from_a_literal[4] = "Y" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment