cces4415 wrote
1. Is there a way to assign multiple values to an Array object? Like in C we write
int ary[10] = {0,1000,1000,1000,1013,1,19,3000,1005,0};
There is no way to assign multiple values in a single statement. The only assignment statement available in Jack is the "let" statement that assigns a single value.
because for some reasons I have to build a constant integer array with size over 200.
2. Is it legal to write "else if"? Or do I have to write stacked "if else"(an if else within another)
All "if" and "else" statements must have braces. When I've needed to write switch-like structures with several cases I've put all the closing braces on the final line:
if (x=1) {
do one();
} else { if (x=2) {
do two();
} else { if (x=3) {
do three();
} else {
do default();
}}}
The Jack language was designed to be very easy to parse and compile since students are going to write a Jack compiler as part of the course. This simple syntax and the limited statement types does, however, make it cumbersome to use for complex programs.
--Mark