Re: New switch/case idea

new topic     » goto parent     » topic index » view thread      » older message » newer message
Fernando said...

Thanks Matt, but what I was trying to ask concerning context was:

  • break inside a switch aborts the switch;
  • But if the switch is inside an if-then statement, break aborts the if-then ?, i.e., break works different if the switch is inside an if-then or not ?

I know. I showed you an analogy using exit.

Fernando said...

IIUC, Jeremy replied that break doesn't depend on the context.

Maybe this example helps me:

X = 1 
condition = 1 
switch X do 
   case 1 then 
      if condition then break end if 
      X = 2 
end switch 
? X 

If that is valid, what will be showed ?

It should print 2, because the break jumps out of the if block. Again, this is just like trying to jump out of a while loop from within a for loop within the while loop.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu