사용자 도구

사이트 도구


groovy:list

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
마지막 판 양쪽 다음 판
groovy:list [2012/11/28 17:50]
kwon37xi [기본값 줘서 리스트 생성]
groovy:list [2015/09/22 14:29]
kwon37xi
줄 1: 줄 1:
-====== Groovy List ======+====== Groovy List / Collection ======
   * [[http://groovy.codehaus.org/Collections|Groovy Collections]]   * [[http://groovy.codehaus.org/Collections|Groovy Collections]]
   * [[http://groovy.codehaus.org/JN1015-Collections|Groovy List and Sets]]   * [[http://groovy.codehaus.org/JN1015-Collections|Groovy List and Sets]]
-  * http://groovy.codehaus.org/groovy-jdk/java/util/List.html+  * [[http://groovy.codehaus.org/groovy-jdk/java/util/List.html|List GDK]] 
 +  * [[http://groovy.codehaus.org/groovy-jdk/java/util/Collection.html|Collection GDK]] 
 +  * [[http://examples.javacodegeeks.com/core-java/groovy-array-example/|Groovy Array Example | Examples Java Code Geeks]]
   * 문자열도 문자의 리스트로 간주할 수 있음.   * 문자열도 문자의 리스트로 간주할 수 있음.
  
줄 36: 줄 38:
 [1, 2, 3].each{ println "Item: $it" } [1, 2, 3].each{ println "Item: $it" }
 ['a', 'b', 'c'].eachWithIndex{ it, i -> println "$i: $it" } // index 를 가지고 each 돌기. index는 0 부터 시작 ['a', 'b', 'c'].eachWithIndex{ it, i -> println "$i: $it" } // index 를 가지고 each 돌기. index는 0 부터 시작
 +
 +// Range는 괄호로 감싸서 each 해야 한다.
 +(0..100).each {
 +  println it
 +}
 </code> </code>
  
줄 47: 줄 54:
 // 50.5 // 50.5
 println list.sum() / list.size() println list.sum() / list.size()
 +</code>
 +
 +===== 기타 =====
 +  * 섞기<code groovy>
 +Collections.shuffle(list, new Random())
 +</code>
 +  * 중복 값 제거<code groovy>
 +assert [3,5,5,5,2].unique() == [3,5,2]
 </code> </code>
  
groovy/list.txt · 마지막으로 수정됨: 2018/06/21 15:48 저자 kwon37xi