Is switch supported / working?

  1. 5 years ago

    Marc

    10 Mar 2019 User since 2018

    From intellisense it seems that the switch statement is supported, but it doesn't seem to be working, unless I'm doing something wrong here:

    var test = 0
    switch (test) {
    	case 0 :
    		Console.write("0")
    		break
    	default :
    		Console.write("default")
    }

    Nothing is written to the console here.

    Is it supported?

    NB: The switch statement isn't mentioned in the documentation, so that could be an indication of being not supported (yet).

  2. marco

    11 Mar 2019 Administrator User since 2016

    You are right, switch is parsed but not yet supported.
    We'll add many features to Gravity in the near future so you can expect it pretty soon.

  3. Marc

    11 Mar 2019 User since 2018

    @marco You are right, switch is parsed but not yet supported.
    We'll add many features to Gravity in the near future so you can expect it pretty soon.

    Ah nice. Also hoping for the "Playground" option to be released soon .... ;)

  4. Marc

    11 Mar 2019 User since 2018

    Also I hope the switch construct will be a bit user friendly than in "C" languages.

    For example not this:

    switch (test) {
    case 1 :
    case 2 :
    Console.write("0")
    break
    default :
    Console.write("default")
    }

    But this:

    switch (test) {
    case 1, 2, 10...15 :
    Console.write("0")
    default :
    Console.write("default")
    }

    The "C"-like way is not a big problem, but I tend to like the BASIC way.

  5. marco

    11 Mar 2019 Administrator User since 2016

    I'd like to follow the Swift way:
    https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html

  6. Marc

    11 Mar 2019 User since 2018
    Edited 5 years ago by Marc

    @marco I'd like to follow the Swift way:
    https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html

    I haven't followed Swift after version 1 (it was too much a moving target), but what I'm reading there now is that, in some code examples, they use the same syntax as I'm suggesting. So if you follow that one I will be happy ;)

or Sign Up to reply!