programming

download

reference:

[!TIP]Java Tutorial :

basic

get environment

Customizable Operators

Operator
Method

a + b

a.plus(b)

a - b

a.minus(b)

a * b

a.multiply(b)

a / b

a.div(b)

a % b

a.mod(b)

a++ or ++a

a.next()

Special Operators

Operator
Meaning
Name

a ? b : c

if(a) b else c

ternary if

a ?: b

a ? a : b

Elvis

a.?b

( a==null ) ? a : a.b

null safe

a(*list)

a(list[0], list[1], ...)

spread

list*.a()

[list[0].a, list[1].a, ...]

spread-out

a.&b

reference to method b in object a as closure

method closure

a.@field

direct field access

dot-at

elvis operator

if/elseif{if}/else

references:

usage

  • ?: ( existing Elvis operator )

  • ?= ( new elvis assignment shorthand )

condition:

  • if fruits is 'apple' or 'orange', get pre-defined number 5 ( number = 5 )

  • if fruits is watermelon, get particular given numbers. number cannot be null

  • example

  • using [ "${fruits}" : '5' ], the class of key is class org.codehaus.groovy.runtime.GStringImpl

  • using [ (fruits) : '5' ] , the class of key is class java.lang.String

execute shell commands in groovy

Get STDERR & STDERR

[!TIP] using new StringBuffer() or new StringBuilder()

i.e.:

or

Show output during the process

using System.out and System.err

  • run.sh

  • resultexecute with environemnt

with system environment

with partular path

reference:

groovyConsole

environment

[!NOTE]

get console details

font

[!NOTE|label:references:]

  • check font

  • modify font

Last updated

Was this helpful?