opposite of << in ruby

Viewed 982

I have a huge string being prepared by using << operator in a loop. At the end I want to delete the last 2 chars.

some_loop
  str << something
end
str = str[0..-3]

I think the last operation above would consume memory and time as well, but I'm not sure. I just wanted to see if there is an operation with the opposite effect of << so I can delete those 2 last chars from the same string.

3 Answers
Related