Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

AS guide: documents String#to and fixes examples

  • Loading branch information...
commit 6aa959e7fc6fd26201e57ff7f498edaf323cb014 1 parent b140979
@fxn fxn authored
Showing with 23 additions and 1 deletion.
  1. +23 −1 railties/guides/source/active_support_overview.textile
View
24 railties/guides/source/active_support_overview.textile
@@ -747,7 +747,29 @@ Returns the character of the string at position +position+:
"hello".at(0) # => "h"
"hello".at(4) # => "o"
"hello".at(-1) # => "o"
-"hello".at(10) # => nil
+"hello".at(10) # => ERROR
+</ruby>
+
+h5. +from(position)+
+
+Returns the substring of the string starting at position +position+:
+
+<ruby>
+"hello".from(0) # => "hello"
+"hello".from(2) # => "llo"
+"hello".from(-2) # => "lo"
+"hello".from(10) # => ""
+</ruby>
+
+h5. +to(position)+
+
+Returns the substring of the string up to position +position+:
+
+<ruby>
+"hello".to(0) # => "h"
+"hello".to(2) # => "hel"
+"hello".to(-2) # => "hell"
+"hello".to(10) # => "hello"
</ruby>
h3. Extensions to +Numeric+
Please sign in to comment.
Something went wrong with that request. Please try again.