TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ruby:

11 pointsby stevefinkover 14 years ago

1 comment

fbcocqover 14 years ago
<i>I think the speed increase comes from += creating a new string object every time, whereas &#60;&#60; literally concatenates it.</i><p>Programming the hunches and guesses way on the HN frontpage makes me sad.<p><a href="http://ruby-doc.org/core/classes/String.html#M000807" rel="nofollow">http://ruby-doc.org/core/classes/String.html#M000807</a><p>str + other_str =&#62; new_str<p>Concatenation Returns a <i>new String</i> containing other_str concatenated to str.<p>str &#60;&#60; fixnum =&#62; str str.concat(fixnum) =&#62; str str &#60;&#60; obj =&#62; str str.concat(obj) =&#62; str<p>Append Concatenates the given object to str. If the object is a Fixnum between 0 and 255, it is converted to a character before concatenation.