Odd behaviour with scala method syntax
Posted
by Ceilingfish
on Stack Overflow
See other posts from Stack Overflow
or by Ceilingfish
Published on 2010-06-13T18:41:15Z
Indexed on
2010/06/13
18:52 UTC
Read the original article
Hit count: 206
scala
Hi chaps, I hit a bit of a quirk of scala's syntax I don't really understand
object Board {
def getObjectAt(x:Int, y:Int):Placeable = return locations(x)(y)
}
works fine. But
object Board {
def getObjectAt(x:Int, y:Int):Placeable {
return locations(x)(y)
}
}
returns the error
Board.scala:8: error: illegal start of declaration
return locations(x)(y)
I found some stuff that says the second form convinces the scala compiler you're trying to specify an expansion to the return type Placeable
. Is there a way I can fix this, or should I just avoid specifying a return type here?
© Stack Overflow or respective owner