View Single Post
Old 07-16-2022, 06:04 PM   #12
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by PeterT View Post
Could you also use a switch statement, rather than lots of elif statements?
Yes. Good point. Switch is effectively a series of "if pattern matches value then result".

One difference is that the chain of elifs stops on a match while a switch evaluates all the pairs then picks the first that matches. The switch is slower if there are matches. In most contexts that probably doesn't matter.
chaley is offline   Reply With Quote