January 2020
Intermediate to advanced
532 pages
13h 31m
English
Our first attempt to implement a command process that may look similar to the following:
function process_command(command::String, args) if command == "open" # open a file elseif command == "close" # close current file elseif command == "exit" # exit program elseif command == "help" # pops up a help dialog else error("bug - this should have never happened.") endend
The process_command function simply takes the command as a string. Then, depending on the value of the string, it will call the respective function. The args argument may be passed by the GUI code for additional information; for example, the path of the file that is being opened or closed.
There is nothing wrong with this code from a logical perspective, ...
Read now
Unlock full access