Learning Scala as a Java Developer - Part 1

I have recently got a chance to develop using Scala, and I thought it would be useful to share my experience (mostly as a guide for myself) to put some notes on what I have learnt in the last few months.

Monads or stuff that you can “map” over

Consider the use of Java Optional type, now this is one very common usage, parsing optional command line args

private void doSomething() {
    Optional<String> someImportantParams = Optional.of("enableThisFeature");

    Configurations config = someImportantParams.map(x -> 
                                                    { Configurations.enable(x); 
                                                    return Configurations });
}

The same example in Scala would look like:

Option[String] someImportantParams = Option("enableThisFeature")

Configurations config = someImportantParams.map {
    Configurations.enable(_)    
}