Exactly, thank you! I believe it is a very good exercise for when you are teaching a programming class.
Another possible exercise is to not use ifs. The way to navigate around that would be to use double dispatch. Not because of any reason of performance gain with the branch predictor like other comments mentioned, but because it adds another tool to your toolbelt