Saturday, February 26, 2011

Scala basic data types

Value type Range
Byte 8-bit signed two’s complement integer (-27 to 27 - 1, inclusive)
Short 16-bit signed two’s complement integer (-215 to 215 - 1, inclusive)
Int 32-bit signed two’s complement integer (-231 to 231 - 1, inclusive)
Long 64-bit signed two’s complement integer (-263 to 263 - 1, inclusive)
Char 16-bit unsigned Unicode character (0 to 216 - 1, inclusive)
Stringa sequence of Chars
Float 32-bit IEEE 754 single-precision float
Double 64-bit IEEE 754 double-precision float
Boolean true or false

Data types shown above reside in package scala except String! String is a member of java.lang package and it's automatically imported therefore it's implicitly converted to scala's WrappedString class (it used to convert to RichString before scala 2.8.1). We can call WrappedString's methods on a string. Voila!

No comments:

Post a Comment