Let's switch out that colon!
#1
When we start a new project in the IDE we see the following
Code:
        switch(msg$(everyCommand))
            case "_QuitRequested":
            case "MainWindow:_QuitRequested":
                leavingLoop = true
                break
            default:
                break
        end switch
Every case and default statement is terminated by a colon ":" That colon has been there as long as I remember

Now I've done a lot of switch loops and sometimes I've left off the colon at the end of a case statement by mistake. Those programs ran flawlessly. Also, yab does not throw up an error if they are missing So, why is it there and what is it supposed to do? the help in the IDE shows that you can do this
Code:
input a
switch(a)
    case 1:print "one":break
    case 2:print "two":break
    default:print "more"
end switch
but that can be done with any set of commands. It is just another way of writing
Code:
input a
switch(a)
    case 1
        print "one"
        break
    case 2
        print "two"
        break
    default
        print "more"
end switch
(BTW shouldn't there be a "break" after "default")

It's a small thing, but every small thing helps make yab a little easier for beginners. If that colon is not actually doing anything, then let's get it out of the templates.
Reply


Messages In This Thread
Let's switch out that colon! - by clasqm - 03-18-2016, 01:56 AM
RE: Let's switch out that colon! - by bbjimmy - 03-18-2016, 08:23 AM
RE: Let's switch out that colon! - by bbjimmy - 03-19-2016, 10:43 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)
Free Web Hosting