Skip to content

Commit

Permalink
Explicitly define mutable strings
Browse files Browse the repository at this point in the history
Ruby 2.3 introduced a magic comment, `frozen_string_literal: true`, that
allows strings to be immutable by default. Ruby 3.4 is preparing to make
this the default behavior and throws deprecation warnings when mutating
strings.

There are many ways to make a mutable string, but I've chosen to use
`String.new` because it is the most explicit option and also doesn't
require creating multiple string objects
  • Loading branch information
HashNotAdam committed Dec 27, 2024
1 parent 3d24c11 commit ec0fff8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/roo/formatters/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def to_yaml(prefix = {}, from_row = nil, from_column = nil, to_row = nil, to_col
from_column ||= first_column(sheet)
to_column ||= last_column(sheet)

result = "--- \n"
result = String.new("--- \n")
from_row.upto(to_row) do |row|
from_column.upto(to_column) do |col|
next if empty?(row, col, sheet)
Expand Down
2 changes: 1 addition & 1 deletion test/roo/test_open_office.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def test_bug_ric
assert workbook.empty?("C", 1)
assert workbook.empty?("D", 1)
expected = 1
letter = "e"
letter = String.new("e")
while letter <= "u"
assert_equal expected, workbook.cell(letter, 1)
letter.succ!
Expand Down

0 comments on commit ec0fff8

Please sign in to comment.