print() and newlines
Jim Laskey (Oracle)
james.laskey at oracle.com
Mon Sep 9 08:41:34 PDT 2013
Hmmm. We originally had print and println, but then we realized it conflicted with rhino and v8
>> rhino
Rhino 1.7 release 5 PRERELEASE 2013 07 05
js> print("hello "); print("world");
hello
world
js> quit();
>> v8
V8 version 3.18.5.2 [console: dumb]
d8> print("hello "); print("world");
hello
world
undefined
d8>
So we changed print to add the newline and dropped println.
You can override easily by declaring.
function print(arg) { java.lang.System.out.print(arg); }
function println(arg) { java.lang.System.out.println(arg); }
Cheers,
-- Jim
On 2013-09-09, at 12:23 PM, Tal Liron <tal.liron at threecrickets.com> wrote:
> There doesn't seem to be a way to open bugs for the project, so I will ask here:
>
> Why does Nashorn's print() add a newline? That makes it different from any other JavaScript implementation out there.
More information about the nashorn-dev
mailing list