I was following the scala course from coursera taught Martin Odersky. He was giving some brilliant examples about return types and one thing puzzled me:
if(true) 1 else false // return AnyVal as this is the closest subtype of both primitive types
I assume that the following:
if(true) Tweet.comment("hello") else String("Hello") // I assume that this code will return AnyRef
However when will scala ever return Any? Will it ever return Any?
I don't know Scala, but based on your examples,
if(true) 1 else "hello"
should probably do the trick.