Switch statements cause compile errors
And when this is fixed, it would also be nice if break statements aren't required. They're silly. I would like something like:
switch foo {
case :bar:
aha()
case :batz:
doSomething()
fallthrough
default
bar()
}
Just an idea.
ideally I'd like to keep compatibility with Javascript. Perhaps there's another way ?
On Tue, Jun 21, 2011 at 5:36 AM, benekastah < [email protected]>wrote:
And when this is fixed, it would also be nice if
breakstatements aren't required. They're silly. I would like something like:switch foo { case :bar: aha() case :batz: doSomething() fallthrough default bar() }Just an idea.
Reply to this email directly or view it on GitHub: https://github.com/weepy/kaffeine/issues/36
There's always the ruby way. That's the best variation of the switch I've used.
// this is only ruby-ish
case thing {
when 'rock', 'roll'
rockNRoll()
else
goHome()
beSad()
}
Then if you really need to use the fallthrough capability, you can just write your switch in pure js.
how about
switch thing
when 'rock', 'roll':
rockNRoll()
else:
beSad()
? do we want/need the colons ?
On Tue, Jun 21, 2011 at 8:31 AM, benekastah < [email protected]>wrote:
There's always the ruby way. That's the best variation of the switch I've used.
case thing when 'rock', 'roll' rockNRoll() else beSad()Reply to this email directly or view it on GitHub: https://github.com/weepy/kaffeine/issues/36#issuecomment-1408559
Yeah, I actually kind of like the colons. It's a little more javascripty, and they help me a bit visually.
yeah agreed.
maybe we don't need the else as it doesn't add anything beyond 'default' ?
On Tue, Jun 21, 2011 at 8:41 AM, benekastah < [email protected]>wrote:
Yeah, I actually kind of like the colons. It's a little more javascripty, and they help me a bit visually.
Reply to this email directly or view it on GitHub: https://github.com/weepy/kaffeine/issues/36#issuecomment-1408599
True. default would be better in this context.
ok so :
switch thing {
when 'rock', 'roll':
rockNRoll()
when 'jazz':
jazz()
default:
beSad()
}
which is converted to :
switch(thing) {
case 'rock':
rockNRoll(); break; case 'roll': rockNRoll(); break;
case 'jazz':
jazz(); break;
default:
beSad()
}
On Tue, Jun 21, 2011 at 8:46 AM, benekastah < [email protected]>wrote:
True.
defaultwould be better in this context.Reply to this email directly or view it on GitHub: https://github.com/weepy/kaffeine/issues/36#issuecomment-1408619