Re: New Switch Idea

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

How about allowing an integer or a sequence between the case keyword and the colon ?

Bernie,

Currently sequences are allowed, but finding of one item in a sequence does not work. We are looking to expand switch/case in 4.1 for some of these options. Here are two examples:

switch "apple" do 
    case "pear": ? 1 
    case "banana": ? 2 
    case "apple": ? 3 
    case "orange": ? 4 
end switch 
 
-- Output: 3 
 
switch 1 do 
    case {1,2,3}: ? 1 
    case {4,5,6}: ? 2 
    case else 
        ? -1 
end switch 
 
-- Output: -1 

Jeremy

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

Search



Quick Links

User menu

Not signed in.

Misc Menu