sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Is this a ruby bug?

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 495 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      tomot
      last edited by

      I'm creating a cross brace ruby, with left or right bracing options
      I wanted to use the keyboard "" to define the brace direction in the dialog box


      bug.png

      [my plugins](http://thingsvirtual.blogspot.ca/)
      tomot

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Within double-quotes [""] in Ruby the back-slash \ has a special-power - it's the 'escape-character' - giving different meanings to some characters that might follow it.
        So to make a \ you must type "\".
        It's also used to make a " - as "1"" [making 1"]; or a new-line in a block of text - as "\n"; or a tab to format text - as "\t" etc.
        That's also why when typing PC paths in Ruby you must either use forward-slashes, or double-up your back-slashes, or use '' instead of ""...
        "C:/Temp/my.skp"
        "C:\Temp\my.skp"
        'C:\Temp\my.skp'
        The MAC always uses / anyway...

        This special-power for \ doesn't always work the same way inside single-quotes [''] - it only applies to \ to make a \ at the very end of a string, or ' to make a ' within a string; it does not apply to the other things like newline or tab that "" uses. So an alternative way of typing a \ could also be '\'
        πŸ€“
        EDIT: Corrected an error in the '' section 😳

        TIG

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomot
          last edited by

          great! "\" works, thanks for the explanation.

          [my plugins](http://thingsvirtual.blogspot.ca/)
          tomot

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @tig said:

            As you see this special-power doesn't work the same way inside single-quotes [''] - so an alternative way of typing a \ would be ''

            This is not correct.

            '\' Error: #<SyntaxError: (eval):155: compile error (eval):155: unterminated string meets end of file> (eval):155

            \ is always an escape character. Even within single quoted string - because you might want to insert a single quote character. So within single quoted string you still have these couple of escape sequences: \' and \\.

            You can use different delimiters if you want to mix ' and " in a string without escaping:
            myString = %&This is "my" String&

            But beware that if you want to include your delimiter you must escape it:
            myString = %&This is "my" \& String&

            More info:
            http://www.techotopia.com/index.php/Ruby_Strings_-_Creation_and_Basics

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              TT you are of course correct.
              Within '' only \' within a string and any final \\ are needed - for example \n doesn't apply as a newline.
              I've adjusted the original post to avoid further confusion πŸ˜’

              TIG

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement