我有要求我将数组作为参数如下 -
arr = ["£12.50", "£1", "£5.00"]
我想从每个数组元素中删除这个“£”符号 我正在使用此代码删除此符号
arr.map! { |amount| amount.delete('£,').to_d }
但是当我尝试执行此操作时,我遇到错误
我正在使用rails 4.2.0
和ruby 2.2.0
有人让我知道如何解决这个问题。
以下是我得到的错误 -
/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/history.rb:106:in write': "\xC2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/history.rb:106:inputs'
from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/history.rb:106:in save_to_file' from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/history.rb:50:incall'
from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/history.rb:50:in push' from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/pry_instance.rb:267:inhandle_line'
from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/pry_instance.rb:243:in block (2 levels) in eval' from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/pry_instance.rb:242:incatch'
from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/pry_instance.rb:242:in block in eval' from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/pry_instance.rb:241:incatch'
from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/pry_instance.rb:241:in eval' from /home/sonus/.rvm/gems/ruby-2.2.0@rtm-new/gems/pry-0.10.3/lib/pry/repl.rb:77:inblock in repl'