You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vara={"Hello","World","Foo","Bar"}varb={1,2,3,4}var c =[10]//Array of size 10vard=[]//Array of variable lengtha[1]//=> "World"append(a,"Baz")//Fail, because a is of fixed size and if you were to add an element, it would be of size 5remove(a,1)//Fail, because a is of fixed size and if you were to remove index 1, it would be of size 3d=append(d,a[0])d=remove(d,0)
var a = {"Hello", "World"}
var b =1..length(a) //!Not an array!; this is a rangefor(var c in b){
print(a[c])
}
for(_ in1..10){
print("Hello world")
}
Special cases
Ranges
var ch ="g"if(ch in"a".."z"){
print("Character is lowercase")
}
var ch ="g"if (ch in"z".."a"){
print("Character is lowercase")
}
Coalesce
vara=null??2
Inline If
var b =if(a ===2){ "Hello" } else { "World" }
Sample Code
var input =in()
var list = []
while(input !=="stop){ list = append(list, input) printList(list) input = in()}fun printList(list){ out("------------------") for(var i in 0..length(list) - 1){ out(list[i]) } out("------------------")}