简体   繁体   English

语法错误,意外的'}',期望::或'['或'。'

[英]Syntax error, unexpected '}', expecting :: or '[' or '.'

row = Hash[new_hash.map { |k, v| k, v.encode("UTF-16BE", invalid: :replace, undef: :replace, replace: '?').encode("UTF-8") }]

This line in a controller causes an syntax error, but I can't find any mistakes. 控制器中的这一行会导致语法错误,但是我找不到任何错误。 Can anyone figure out what's going wrong? 谁能找出问题所在?

This is a Rails application. 这是一个Rails应用程序。 Ruby 2.2.0 and Rails 4.2.0 . Ruby 2.2.0Rails 4.2.0

You forgot brackets ( [] ). 您忘记了方括号( [] )。 It should be: 它应该是:

row = Hash[new_hash.map{ |k, v| [k, v.encode("UTF-16BE", invalid: :replace, undef: :replace, replace: '?').encode("UTF-8")] }]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM