Re: New switch/case idea

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

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

I said that break breaks from it's enclosing statement, whatever that may be, a switch or if.

Fernando said...

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 ?

That will print 2. break broke from the if, not the switch. Now, if you want it to break from the switch, you would:

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

Now X will print 1.

Jeremy

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

Search



Quick Links

User menu

Not signed in.

Misc Menu