var total = {
var value = [1..10];
var sum = 0;
for( v in value){
sum = sum + v;
}
sum;
}If Else block:
var a = 4;
if(a>5){
println("4 is greater than 5");
}else{
println("4 is less than 5");
}Range expression:
var seq = [1..100];
var seq2 = [1..100 step 2];var seqDesc = [100..1 step -1];
For expression:
var data = [1..100 step 2];
for(d in data){
println(d);
}While expression:
var i = 0;
while(i<10){
println(i);
i++;
}
No comments:
Post a Comment