Code · 1 file
Sample Groovy File
Groovy is a dynamic JVM language used for Gradle builds and Jenkins pipelines. Every language sample implements the same small program so you can compare them side by side.
Groovy · 501 B
Sample Groovy file
An idiomatic Groovy example — the same customer program (or, for hardware languages, a small counter design) we offer in every language.
CC0 · free for any use · Verified by an independent tool · Report a problem
// Sample Groovy script — samplefiles.com
class Customer {
int id
String name
BigDecimal balance
boolean isVip() { balance >= 10_000 }
}
def customers = [
new Customer(id: 1, name: 'Ada', balance: 12_500.00),
new Customer(id: 2, name: 'Grace', balance: 830.50),
new Customer(id: 3, name: 'Linus', balance: 10_000.00),
]
customers.each { c ->
printf('%-6s %10.2f %s%n', c.name, c.balance, c.vip ? 'VIP' : '')
}
printf('Total: %.2f%n', customers.sum { it.balance })File details
Download from the command line
curl -L -o sample.groovy https://files.samplefiles.com/code/groovy/sample.groovywget https://files.samplefiles.com/code/groovy/sample.groovyhttps://files.samplefiles.com/code/groovy/sample.groovyprintf '%s %s\n' abc0c4962d99079c495dc137b44ac552f5d845ef393d625d6d8ee6606dcbed8c sample.groovy | shasum -a 256 -cOr check the download in your browser with the checksum calculator.