Code Monkey home page Code Monkey logo

Comments (7)

weepy avatar weepy commented on July 22, 2024

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 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.

Reply to this email directly or view it on GitHub:
#36

from kaffeine.

benekastah avatar benekastah commented on July 22, 2024

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.

from kaffeine.

weepy avatar weepy commented on July 22, 2024

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:
#36 (comment)

from kaffeine.

benekastah avatar benekastah commented on July 22, 2024

Yeah, I actually kind of like the colons. It's a little more javascripty, and they help me a bit visually.

from kaffeine.

weepy avatar weepy commented on July 22, 2024

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:
#36 (comment)

from kaffeine.

benekastah avatar benekastah commented on July 22, 2024

True. default would be better in this context.

from kaffeine.

weepy avatar weepy commented on July 22, 2024

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. default would be better in this context.

Reply to this email directly or view it on GitHub:
#36 (comment)

from kaffeine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.