Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save repeatedly/3128808 to your computer and use it in GitHub Desktop.
Save repeatedly/3128808 to your computer and use it in GitHub Desktop.
Why Ruby failed to parse a Hash literal with multiple here documents.

1 element

h = { 
  hoge: <<EOS
Hey!
EOS
}

p h

print:

% ruby a.rb
{:hoge=>"Hey!\n"}

multiple elements

h = {
  hoge: <<EOS
Hey!
EOS
  ,
  fuga: <<EOS
Yo!
EOS
}

p h

print:

% ruby a.rb
a.rb:5: syntax error, unexpected ',', expecting '}'
a.rb:9: syntax error, unexpected '}', expecting $end

Why?

Resolved!

Thanks to @hideo55 ! See: https://gist.github.com/3128882

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment