Toshihiro Yokota
Toshihiro Yokota

Reputation: 103

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. Ruby 2.2.0 and Rails 4.2.0.

Upvotes: 0

Views: 502

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51151

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")] }]

Upvotes: 2

Related Questions