January 2020
Intermediate to advanced
532 pages
13h 31m
English
We know that our implementation of the move functions comes with some implicit design assumptions:
For these reasons, it's generally safer to define functions with some type information. Having said that, the move_up! function can be redefined as follows:
move_up!(widget::Widget, v::Int) = widget.position.y -= v
If we just define all move functions the same way, then debugging becomes easier. Suppose that we make the same mistake as we did in the preceding code by passing an integer as the first argument: ...
Read now
Unlock full access