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
  • 76,625
  • 45
  • 224
  • 313

2 Answers2

22

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,571
  • 2
  • 22
  • 35
13

Use the right syntax:

scala> print("Hello")
Hello
om-nom-nom
  • 61,565
  • 12
  • 180
  • 225
  • 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