提交 9ab8cfc2 编写于 作者: J José Valim

Improve the idiom used in multibyte chars a bit.

上级 265b7c5e
......@@ -316,12 +316,12 @@ def slice(*args)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册