File: file.groovy

package info (click to toggle)
gtksourceview4 4.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,840 kB
  • sloc: ansic: 49,715; sh: 4,917; xml: 1,302; makefile: 1,010; python: 230; perl: 52; yacc: 45; cobol: 20; objc: 19; sed: 16; fortran: 14; cpp: 8; ml: 3
file content (55 lines) | stat: -rw-r--r-- 1,385 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env groovy

// Single-line comment. TODO markers work.
/* Multi-line comment.
   TODO markers work. */

'line' \
    + 'continuation'

def tsq = '''Triple single-quoted string.

    Escapes work: \' \n \123 \u12ab \
    Interpolation doesn't work: $x ${x}
'''

def sq = 'Single-quoted string. Escapes work: \' \r \45 \u45CD \
    Interpolation does not: $x ${x}'

def tdq = """Triple double-quoted string.

    Escapes work: \" \f \6 \uABCD \
    Interpolation works: $x._y.z0 ${x + 5}
"""

def dq = "Double-quoted string. Escapes work: \" \b \7 \u5678 \
    So does interpolation: $_abc1 ${x + "abc"}"

def slashy = /Slashy string.

    There are only two escape sequences: \/ \
    Interpolation works: $X ${-> X}
    Dollars $ and backslashes \ on their own are interpreted literally./

def notSlashy = 1 /2/ 3 // not a slashy string; just two division operators

def dollarSlashy = $/Dollar slashy string.

    There are three escape sequences: $$ $/ \
    Interpolation works: $_ ${true}
    Dollars $ and backslashes \ on their own are interpreted literally./$

0b10i + 0b0110_1011 // binary numbers
0 + 123L + 456_789 // decimal numbers
0xab + 0xcd_efG // hexadecimal numbers

01_23.45_67g + 1e-23f + 2d + 08.80 // floating-point numbers

trait Test {
    void foo(List list) {
        def sum = 0
        for (n in list) sum += n as int
        println sum
    }
}