January 2020
Intermediate to advanced
532 pages
13h 31m
English
Another usage of the let block is to limit the scope of variables in a long Julia script or function. In a long script or function, the code could be difficult to follow if we declare a variable at the top and use it throughout the body. Instead, we can write a series of let blocks, which operate independently with their own bound variables. By limiting the bounded variables in smaller blocks, we can follow the code more easily.
While writing long script/functions is not a generally recommended practice, we can find them occasionally in testing code, which tends to be quite repetitive. In test scripts, we may have many test cases that are grouped in the same test set. Here is an example ...
Read now
Unlock full access