2차원 배열 혹은, 특정한 값으로 차있는 배열을 만들고자 하면 다음과 같이 사용.
결국에는 아래 두개의 문장은 같은 결과를 내보인다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sth1 = Array.fill(3,3)(false) //> sth1 : Array[Array[Boolean]] = Array(Array(false, false, false), Array(false | |
//| , false, false), Array(false, false, false)) | |
val sth2 = Array.ofDim[Boolean](3,3) //> sth2 : Array[Array[Boolean]] = Array(Array(false, false, false), Array(fals | |
//| e, false, false), Array(false, false, false)) | |
'소프트웨어 개발 > Scala - Functional' 카테고리의 다른 글
순회 출력 (0) | 2016.09.16 |
---|---|
스칼라 loop break (0) | 2016.09.14 |
Scala 문자열과 일치 여부 (0) | 2016.07.30 |
[참고자료] fork in run (0) | 2015.12.28 |
[스칼라 알고리즘] 단순 원소 바꾸기, 배열 회전 (0) | 2015.06.03 |