String Builder Optimization (ARCH6071)
Esta página aún no está disponible en tu idioma.
Key ruby.performance.string-builder-optimization · Severity info · Category performance
Chaining many + operands in one expression allocates a new string at every intermediate step. Use interpolation, format, or join instead.
Incorrect
Section titled “Incorrect”def label(user) "Name: " + user.first + " " + user.last + " (" + user.id.to_s + ")"endCorrect
Section titled “Correct”def label(user) "Name: #{user.first} #{user.last} (#{user.id})"endReplace long + chains with string interpolation or format/join.