Monday, November 28, 2011

casting and scala

since a couple of month's I work more and more with scala and really start to like this language. But some of the concepts are really confusing and make me wounder if this really is necceasary.

A prime example would be the whole casting of variables.

In java you simple do:

String value = (String)object;

now in scala

val value:String = object.asInstanceOf[String]

now I admit it looks very clean, but sure took a while to find this one little details.

Otherwise it's always better to use matchers.

No comments:

Post a Comment