scala Collections

scala 2016. 3. 15. 17:16

Array: mutable이고  java와 달리, (0),(1)로 마치 함수호출 하듯이 element get함.


List : immutable이고 동일한 type을 보관

tuple: immutable이고 서로 다른 type의 데이타를 저장할 수 있다. 


HashSet, HashMapt: mutable   (Set,Map은 trait임)

예) val s = new HashSet[String] 

    s += "AA"

예) val m = new HashMap[Int, String]

    m += (1 -> "Go to Hell") 


<immutable Set/Map> - factory method방식으로 이용가능.

    예) val s = Set("A", "BB", "CC")            : compoiler transfers as Set.apply()

   예) val s = Map(1 -> "AA", 2->"BB")       : compoiler transfers as Map.apply()




요약하면 immutable List,Tuple,  Set,Map이 존재한다.



Posted by yongary
,