Maybe it's just me, but after using hundreds of switch/case commands, I think I've found one use for have one case statement drop through to the next by omitting the break statement. Conversely, I've been bitten a lot by forgetting to include a break statement.
I don't suppose there's a setting/trick/technique that makes it unnecessary to include break statements....
Pete
case/break
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Hi Pete,
There is no way to make the break unnecessary. Break is very useful though:
This is a silly example, but it is provides a good way to illutrate the mechanism.
Best,
Mark
There is no way to make the break unnecessary. Break is very useful though:
Code: Select all
switch theNumber
case 1
case 3
case 5
case 7
case 9
put "The number was odd"
break
default
put "The number was even"
end switch
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Thanks Mark. I understand that it can be useful sometimes and I have made use of it but I'd say 90% or more of the time, I have to use break so to me it would be better if the default was not to drop through and there was another command/keyword that could be used when you do want to drop through to the next case, something like 'continue' perhaps.
Anyway, it's not a big deal, I guess I'm new enough to Rev that I still get annoyed with myself when I forget to use break and weird things hapen!
Pete
Anyway, it's not a big deal, I guess I'm new enough to Rev that I still get annoyed with myself when I forget to use break and weird things hapen!
Pete