m.....u konto usunięte 28.02.2016, 10:54:36 3 + Czemu Elvis operator? Odwróć głowę w lewo, a się dowiesz ( ͡° ͜ʖ ͡°)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!'#groovy
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!'
#groovy