jah
parent
52f4e92000
commit
67fa3e9ec4
14
notizen.md
14
notizen.md
|
@ -39,21 +39,21 @@ Strandardmäßig werden in Groovy Strings aus der Klasse _java.lang.String_ benu
|
|||
Platzhalter im Stringliteral, handelt es sich um einen GString aus der Klasse _groovy.lang.GString_
|
||||
|
||||
```
|
||||
def welt = "World!"
|
||||
def hallo = "Hello ${welt}"
|
||||
print hallo // "Hello World!"
|
||||
def welt = "World!"
|
||||
def hallo = "Hello ${welt}"
|
||||
print hallo // "Hello World!"
|
||||
```
|
||||
|
||||
Es ist auch erlaubt Berechnungen innerhalb des Platzhalters durchzuführen. Auch das wäre also ein gültiger Groovy Code:
|
||||
|
||||
```
|
||||
def str = "2 + 3 ergibt: ${2+3}";
|
||||
print str // "2 + 3 ergibt: 5
|
||||
def str = "2 + 3 ergibt: ${2+3}";
|
||||
print str // "2 + 3 ergibt: 5
|
||||
```
|
||||
|
||||
Man darf sogar mehrere Statements innerhalb des Platzhalters verwenden, jedoch wird empfohlen dies zu vermeiden.
|
||||
|
||||
```
|
||||
def str = "The sum of 1 and 2 is equal to ${def a = 1; def b = 2; a + b}"
|
||||
print str // "The sum of 1 and 2 is equal to 3"
|
||||
def str = "The sum of 1 and 2 is equal to ${def a = 1; def b = 2; a + b}"
|
||||
print str // "The sum of 1 and 2 is equal to 3"
|
||||
```
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
public class Hi {
|
||||
public static void main (String [] args) {
|
||||
new Hi().this()
|
||||
}
|
||||
|
||||
def "this"(){
|
||||
print "hello"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue