2016-04-26 7 views
0

グラデルスクリプトで - >演算子とは何を意味しますか?それはグルーヴィーなものですか?例えば。グラデーションスクリプトで - >の意味

def configureWarnings = { compiler -> 
     compiler.args '-Wno-long-long', '-Wall', '-Wswitch-enum', '-pedantic', '-Werror' 
} 

OR

all { binary -> 
    binary.component.sources.cpp.libs.each { lib -> 
     if (lib instanceof Map && lib.containsKey('library') { 
     //blah 
     } 
     if (lib instanceof Map && lib.containsKey('library')) { 
     //blah 
     } 
    } 
    } 
+0

http://groovy-lang.org/closures.html –

答えて

1

それは閉鎖のパラメータのグルーヴィーな構文です。 Groovyで詳細

0

ためSee here、この構文:

クロージャ本体から引数を分離するのに役立ちます。あなたが複数のパラメータを持っている場合には

Closures Refference

彼らは、カンマで区切られています。

簡単な例は次のようになります。

def list = ['a', 'b', 'c'] 

list.each { listItem -> 
    println listItem 
} 

になりますどの:このコンテキストでは

a 
b 
c 

、あなたもパラメータを省略し、ネイティブコールそれを使用することができます。コードは次のようになります。

def list = ['a', 'b', 'c'] 

list.each { 
    println it 
} 

結果は同じでなければなりません。

マップを持っている場合、たとえば、あなたはそれがこのようなキーと値です区切ることができます:

def map = ['Key_A':'a', 'Key_B':'b', 'Key_C':'c'] 
map.each { key, value -> 
    println "$key has the value $value" 
} 

当然、結果は次のようになります。

Key_A has the value a 
Key_B has the value b 
Key_C has the value c 

私が助けてきたことを願っています。