-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Philip Ford edited this page Jan 12, 2017
·
30 revisions
The following packages are automatically imported by Groovy, so you don't have to import them:
import java.lang.*
import java.util.*
import java.io.*
import java.net.*
import groovy.lang.*
import groovy.util.*
import java.math.BigInteger
import java.math.BigDecimalA more concise ternary operator: ?:
def sampleText
// Normal ternary operator.
def ternaryOutput = (sampleText != null) ? sampleText : 'Hello Groovy!'
// The Elvis operator in action. We must read: 'If sampleText is not null assign
// sampleText to elvisOuput, otherwise assign 'Viva Las Vegas!' to elvisOutput.
def elvisOutput = sampleText ?: 'Viva Las Vegas!'