In [ ]:
def a = 1 //local variable
b = 2 //global variable

In [ ]:
a //error

In [ ]:
b //this works

In [ ]:
//closure example
timesTwo = {x -> x*2}

In [ ]:
timesTwo(4)

In [ ]:
timesTwo("Multiplying Strings!")

In [ ]:
sin(3.1415)

In [ ]:
import java.nio.charset.Charset;

byte[] cp1251Bytes = new byte[3];
cp1251Bytes[0] = (byte) 0xFD;
cp1251Bytes[1] = (byte) 0xFE;
cp1251Bytes[2] = (byte) 0xFF;

byte[] utfBytes = new byte[6];
utfBytes[0] = (byte) 0xD1;
utfBytes[1] = (byte) 0x8D;
utfBytes[2] = (byte) 0xD1;
utfBytes[3] = (byte) 0x8E;
utfBytes[4] = (byte) 0xD1;
utfBytes[5] = (byte) 0x8F;

String cp1251Str = new String(cp1251Bytes, Charset.forName("CP1251"));
byte[] utfBb = cp1251Str.getBytes(Charset.forName("UTF-8"));
for(byte b: utfBb){
    System.out.print((String.format("%x", b)));
}

new Plot(
    title: new String(cp1251Bytes, Charset.forName("CP1251")), 
    xLabel: new String(utfBb, Charset.forName("UTF-8")), 
    yLabel: new String(utfBytes, Charset.forName("UTF-8")))

In [ ]:
3 + 2

In [ ]:
// cell10
beakerx.getCodeCells('tg1')[0].outputs

In [ ]:
// cell10 expected result
Image("../../resources/img/groovy/groovy/cell10_case1.png")

In [ ]:
// cell11
lst = []
lst << ['hours':10]

In [ ]:
// cell11 expected result
Image("../../resources/img/groovy/groovy/cell11_case1.png")

In [ ]:
// cell12
[a: null, b:1]

In [ ]:
// cell12 expected result
Image("../../resources/img/groovy/groovy/cell12_case1.png")

press 'Tab' for autocomplete


In [ ]:

press 'Shift' + 'Tab' for doc


In [ ]:


In [ ]: