diff options
author | José Valim <jose.valim@gmail.com> | 2010-06-30 15:01:23 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-30 15:01:23 +0200 |
commit | 9ab8cfc21ab07b9a65388ce3643e5558642dbc2a (patch) | |
tree | 17dfd85321420f1c35bd1e9c553a4718a577e38e | |
parent | 265b7c5edfe9b60d1ab547bfef569d94df05b8e9 (diff) | |
download | rails-9ab8cfc21ab07b9a65388ce3643e5558642dbc2a.tar.gz rails-9ab8cfc21ab07b9a65388ce3643e5558642dbc2a.tar.bz2 rails-9ab8cfc21ab07b9a65388ce3643e5558642dbc2a.zip |
Improve the idiom used in multibyte chars a bit.
-rw-r--r-- | activesupport/lib/active_support/multibyte/chars.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 9251b26f62..8823e4a5ed 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -316,12 +316,12 @@ module ActiveSupport #:nodoc: result = @wrapped_string.slice(*args) elsif args.size == 1 && args[0].kind_of?(Numeric) character = Unicode.u_unpack(@wrapped_string)[args[0]] - result = character.nil? ? nil : [character].pack('U') + result = character && [character].pack('U') else cps = Unicode.u_unpack(@wrapped_string).slice(*args) - result = cps.nil? ? nil : cps.pack('U*') + result = cps && cps.pack('U*') end - result.nil? ? nil : chars(result) + result && chars(result) end alias_method :[], :slice |