Wednesday, September 20, 2017

Scala Tutorial 4 - Data Types and Variables



Strong typing is very important in functional programming

Most scripting like Ruby, Python, etc. are dynamically typed, which is supposed to be one of their advantages.

Static typing makes programming much safer.

But sometimes types declarations become a burden.

Scala’s type inferencing mechanism minimizes the number of type declarations required.

It’s not uncommon for user code to have no explicit types.



Data Types Byte : 8 bit signed value. Range from -128 to 127

Short : 16 bit signed value. Range -32768 to 32767 Int : 32 bit signed value. Range -2147483648 to 2147483647

Long : 64 bit signed value. -9223372036854775808 to 9223372036854775807

Float : 32 bit IEEE 754 single-precision float

Double : 64 bit IEEE 754 double-precision float Char : 16 bit signed Unicode character. Range from U+0000 to U+FFFF

String : A sequence of Chars

Boolean : Either the literal true or the literal false Unit: Corresponds to no value : void

Null: null or empty reference

Nothing : The subtype of every other type; includes no values Any: The supertype of any type; any object is of type

Any : Java's Object class

AnyRef: The supertype of any reference type





-------------------------Follow-------------------

My Website - http://www.codebind.com

My Blog - https://goo.gl/Nd2pFn

My Facebook Page - https://goo.gl/eLp2cQ

Google+ - https://goo.gl/lvC5FX

Twitter - https://twitter.com/ProgrammingKnow

Pinterest - https://goo.gl/kCInUp

Text Case Converter - https://goo.gl/pVpcwL

Epoch Timestamp Converter - https://goo.gl/Zedjo5

Decimal - Binary - Hexadecimal Converter - https://goo.gl/rkX3JE

8-bit Checksum Calculator - https://goo.gl/inxvIT