Scala Coding Style Guide:- InShort

Knoldus Blogs

We all are using the Scala for a very long time now and sometimes we miss some guidelines for writing the Scala code, well this blog guide you through some common Scala coding styles. Lets get started.

  • Indentation:- Scala follows 2 space indentation instead of 4 spaces, well I guess there will be no fight over Tab and 4 Spaces.
    //WRONG                                //RIGHT              
    classFoo{                            class Foo {          
        defbar= ...                        defbar= ...      
    }                                      }                    
  • Line Wrapping:- There are times when a single expression reaches a length where it becomes unreadable to keep it confined to a single line. Scala coding style prefers if length of a line crosses 80 characters then, split the same in multiple lines i.e.
    val result = 1 + 2 + 3 + 4 + 5 + 6 +
      7 + 8 + 9 + 10 + 11 + 12 + 13

View original post 460 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s