Re: New switch/case idea

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

That should still work in Euphoria too, but it doesn't at the moment. I think this is a bug. To get it to work currently you have to add a label to the break clause...

  switch X label "A" do 
      case 1 then 
      . . . 
         if cond then 
             break "A" 
         end if 

Oops, no its not a bug. The break statement can also be used inside if statements to break out of a deeply nested if. So a break without a label and inside an if just skips to the end if line.

Does that mean the meaning of break depends on context ?

For example,

X = 1 
condition = 1 
if condition then 
   switch X with fallthru do 
      case 1 then 
         ? 1 
         break    -- exit switch or if ?? 
      case 2 then 
         ? 2 
   end switch 
   ? 3 
end if 
 
--shows: 
-- 1 ? 
-- or 
-- 1  
-- 3 ? 

- Fernando

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

Search



Quick Links

User menu

Not signed in.

Misc Menu