Primitive Types in Scala

Java supports primitive types – byte, short, char, int etc.

Scala doesn’t – these are implemented as classes, similar to the java classes Byte, Long etc.

Declaring is simple when explicitly declaring type:

val i:Int = 5

and terse when letting the compiler work it out:

val i = 5

Might be worth noting here, ‘val’ declares that a value will be a constant (final).

Advertisements

One thought on “Primitive Types in Scala

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s