Program Flow Flashcards

1
Q

What branching logic is available in PS?

A
if(test){
}
elseif(){
}
else{
}
switch($var){
  test {dosomething
         break}
  test2 {}
  default {}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do we create multiple statements on a single line in PS.

A

Use semi-colon.

$v = 1; $v2 = 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we make switch work with collections?

A
Just use the collection in the switch test:
switch(1..5)
{
  #Tests go here
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can we make switch tests case-insensitive?

A

use the -caseinsensitive switch

switch -caseinsensitive(“Blah”){}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can we make switch tests use wildcards

A

Use the -wildcard switch and then use wildcard characters in the switch tests:

switch -Wildcard (“Blah”){
“Bl*” {DoSomething}
“?la?” {DoSomethingElse}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly