Aravind Yarram
Aravind Yarram

Reputation: 80176

Scala REPL: error: ';' expected but string literal found

What is wrong with this simple text book REPL?

C:\Users\abc>scala
Welcome to Scala version 2.11.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> print "Hello"
<console>:1: error: ';' expected but string literal found.
       print "Hello"
             ^

scala>

This is supposed to print "Hello"

Upvotes: 5

Views: 16800

Answers (2)

Jasper-M
Jasper-M

Reputation: 15086

It does work if you ask nicely:

scala> object please {
     |   val print = Predef.print _
     | }
defined module please

scala> please print "Hello"
Hello

Upvotes: 23

om-nom-nom
om-nom-nom

Reputation: 62835

Use the right syntax:

scala> print("Hello")
Hello

Upvotes: 13

Related Questions