Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

AS guide: documents String#squish

  • Loading branch information...
commit 49a23ad4218e2b37eb3a77091b26eb9308246e39 1 parent db41df2
@fxn fxn authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 railties/guides/source/active_support_overview.textile
View
10 railties/guides/source/active_support_overview.textile
@@ -682,6 +682,16 @@ h4. +bytesize+
Ruby 1.9 introduces +String#bytesize+ to obtain the length of a string in bytes. Ruby 1.8.7 defines this method as an alias for +String#size+ for forward compatibility, and Active Support does so for previous versions.
+h4. +squish+
+
+The method +String#squish+ strips leading and trailing whitespace, and substitutes runs of whitespace with a single space each:
+
+<ruby>
+" \n foo\n\r \t bar \n".squish # => "foo bar"
+</ruby>
+
+There's also the destructive version +String#squish!+.
+
h3. Extensions to +Numeric+
...
Please sign in to comment.
Something went wrong with that request. Please try again.