Unintuitive here document behavior: bug or feature?

Jim Laskey (Oracle) james.laskey at oracle.com
Mon Feb 23 12:54:23 UTC 2015


Feature - the heredoc doesn't begin until the next line (multi-LINE string.)  This makes the JS code visually clearer.

-- Jim

On Feb 22, 2015, at 7:12 AM, Anthony Vanelverdinghe <anthony.vanelverdinghe at gmail.com> wrote:

> Hi
> 
> When using a here document, statements that are on the same line as the initial <<EOD are interpreted as JavaScript & executed after the "heredoc statement". Is this a bug or a feature?
> 
> For example:
> 
> var a = 2;
> print(<<EOD); a = 3; print("here")
> a++;
> ${a}
> EOD
> print(a);
> 
> prints
> 
> a++;
> 2
> here
> 3
> 
> Kind regards, Anthony



More information about the nashorn-dev mailing list