-
Notifications
You must be signed in to change notification settings - Fork 0
Control Flow
Liu Jun edited this page Dec 9, 2019
·
4 revisions
You still can write for like the one in C++.
for(int i=0; i < 10; ++i) // implemented
{
//do something...
}
while(true){ // unimplemented
// ...
}
And you can use foreach to make it easier. It's not necessary to point out the type explictly.
// unimplemented
for (&val : arr){
//use the value in the arr to traverse
//& means using it by reference, otherwise it will be copied
}
for (it : arr.iterator()){
//use itertor
}
for (i : arr.index()){
//use index {0,1,2,...}
}
if is just the same as the one you know in C++.
// implemented
if(/*any condition*/)
{
//do something
}