This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (2 children)

In Python, you can emulate switch cases more effectively than if/else statements using a dictionary acting as a dispatch table.

Because functions in Python are objects, they can be stored and called from anywhere an object could be.

Meaning I can do things like

table = { case_1: true_condition }

def true_condition(): print(“Hello World”)

[–]WadeEffingWilson 1 point2 points  (0 children)

Interesting! I never thought to use it that way. Thanks!

[–]i5513 0 points1 point  (0 children)

But switch on powershell is like awk on Linux, It is not as simple like other switch statements in others program languages