Double, Float, Long, Int, Short, Byte, Char, Unit, Boolean
Unit은 의미가 없음을 의미합니다.
Java의 마치 void와 비슷해보인다.
AnyRef
reference Type을 의미 합니다.
value type이 아닌 타입들이 존재합니다.
JVM에서 Scala를 사용하는 경우 자바의 java.lang.Object와 일치합니다.
Example
val list: List[Any] = List( "a string", // -> a string 732, // an integer // -> 732 'c', // a character true, // a boolean value () => "an anonymous function returning a string" // -> <function>)list.foreach(element => println(element))
Type Casting
Byte → Short → Int → Long → Float → Double
Char → Int
Example
val x: Long = 987654321val y: Float = x // 9.8765434E8val face: Char = '😂'val number: Int = face // 9786
Example - not compile
Float에서 Long으로 Compile이 되지 않는다.
val x: Long = 987654321val y: Float = x // 9.8765434E8val z: Long = y // Does not conform