From 4a5396c0645fff3de924435c3334e2ad33d01799 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 24 Aug 2009 22:23:37 +0200 Subject: AS guide: documents String#each_char --- railties/guides/source/active_support_overview.textile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile index ae25438825..fbdc204cee 100644 --- a/railties/guides/source/active_support_overview.textile +++ b/railties/guides/source/active_support_overview.textile @@ -729,6 +729,13 @@ in case you feel more comfortable spelling them that way. WARNING. Active Support invokes +to_s+ on the argument, but Ruby does not. Since Active Support defines these methods only if strings do not respond to them, this corner of their behaviour depends on the interpreter that runs a given Rails application. You change the interpreter, and +start_with?(1)+ may change its return value. In consequence, it's more portable not to rely on that and pass always strings. +h4. +each_char+ + +Ruby 1.8.7 and up define the iterator +String#each_char+ that understands UTF8 and yields strings with a single character each, so they have length 1 but may be multibyte. Active Support defines that method for previous versions of Ruby: + + +"\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E".each_char {|c| print c} # => 日本語 + h3. Extensions to +Numeric+ -- cgit v1.2.3