Difference Between Single and Double Quoted Strings in ActionScript

前端 未结 5 1118
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 16:53

Is there any difference between single and double quoted strings in ActionScript?

相关标签:
5条回答
  • 2020-12-11 17:22

    No, apart from it being easier to include single quotes in double quoted strings and vice versa.

    0 讨论(0)
  • 2020-12-11 17:23

    No.

    // * required - at least 15 characters

    0 讨论(0)
  • 2020-12-11 17:26

    There is no difference.

    This is from ActionScript: The definitive Guide:

    String is the datatype used for textual data (letters, punctuation marks, and other characters). A string literal is any combination of characters enclosed in quotation marks:

        "asdfksldfsdfeoif"  // A frustrated string
        "greetings"         // A friendly string
        "moock@moock.org"   // A self-promotional string
        "123"               // It may look like a number, but it's a string
        'singles'           // Single quotes are acceptable too
    
    0 讨论(0)
  • 2020-12-11 17:32

    You can use either as delimiter for a string. They are however not interchangeable, i.e. you can't start a string with an apostrophe and end it with a quotation mark.

    The only difference is which characters you need to escape. Inside a string delimited by quotation marks you need to escape quotation marks but not apostrophes, and vice versa.

    To put the text He said "It's all right" and laughed. in a string you can use:

    "He said \"It's all right\" and laughed."
    

    or:

    'He said "It\'s all right" and laughed.'
    
    0 讨论(0)
  • 2020-12-11 17:45

    In Actionscript itself, there are not differences, other than the availability of the unused delimiter without escape characters.

    In Flash Builder, a common AS3 authoring IDE for Flex, autocomplete for compatible event types (e.g., Event.COMPLETE) on addEventListener will not work if those event types are defined with single quotes rather that double quotes.

    Suppose you have a class a tag it as dispatching a particular event type with the Flex meta tag.

    [Event(name="foo",type="pkg.events.Constants")]
    class SomethingThatDispatchesFoo extends EventDispatcher {
    

    If your event constant class is structured like this:

    class Constants {
      public static const FOO:String = 'foo';
    }
    

    Then autocomplete will give you 'foo'. However, if it's structured like this:

    class Constants {
      public static const FOO:String = "foo";
    }
    

    The autocomplete will give you Constants.FOO.

    0 讨论(0)
提交回复
热议问题