5

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"

Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327

2 Answers2

23

It does work if you ask nicely:

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

scala> please print "Hello"
Hello
Jasper-M
  • 14,966
  • 2
  • 26
  • 37
13

Use the right syntax:

scala> print("Hello")
Hello
om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
  • 2
    @Pangea it depends. [Sometimes, you can drop parenthesis, sometimes, you're not](http://stackoverflow.com/q/1181533/298389) – om-nom-nom Jun 23 '14 at 15:15