sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Some critique

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 5 Posters 454 Views 5 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.
    • B Offline
      ben.doherty
      last edited by

      I made some Ruby tutorials for sketchup to use in our office. They are a but rough around the edges as they've not really stretched their legs yet. I'd be really interested in getting some feedback on them. If anyone fancies having a look at them then I'd be really grateful!

      Link Preview Image
      BVN ruby lessons

      learning think in Ruby

      favicon

      BVN ruby lessons (bvnruby.wordpress.com)

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Lesson 1

        @unknownuser said:

        Variables are places to store information, a bit like a jar. Lets make a jar to put our name in.

        Ruby does NOT have variables, despite what some texts say, nor what some of the query methods are named, like: .instance_variables().

        Ruby is a 100% OOP language. Ruby has 2 "kinds" of things, objects and references that point at objects. If you teach your students to think about Ruby references, the way they think about BASIC variables, you will set them up for frustration down the road.

        In Ruby = is not "equals", it is the reference assignment operator. (== is the equality comparison operator or method.)

        see these topics:

        • Re: By value or by reference?* This tripped me up (again) today

        @unknownuser said:

        There are lots of different types of variables:

        numbers: 1, 5000, 20, or like 4.5, -700.45

        strings: 'hello world', "my style is the best"

        Booleans: true, false

        This should read, "There are many different classes of objects"

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • honoluludesktopH Offline
          honoluludesktop
          last edited by

          Dan, Help me out. As a old timer that cut his tooth on pre-OPPS, what is the equivalent of a C variable in OPPS?

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

            Dan is trying to explain the correct terminology
            model=Sketchup.active_model sets a reference named 'model' to the Sketchup active_model object.
            In layman speak you set the variable named 'model' equal to the Sketchup active_model.
            A reference is what you might [sloppily] call a variable and using 'equal' because it uses a = sign is also potentially confusing as == tests for equality, whilst = assigns a reference.
            Assigning a 'reference' also has different effects depending on the 'type' [class] of object referenced
            With numbers...
            x=1 returns 1
            y=x returns 1
            y=2 returns 2
            but then
            x still returns 1 as x and y are not 'linked'.
            BUT
            xyz=[1,2,3] returns 1,2,3
            abc=xyz returns 1,2,3
            abc[0]=0 returns 0,2,3
            but now
            xyz returns 0,2,3 too, because abc AND xyz refer to the same array, changing one reference changes the other, as they are both referring to the same thing...
            To make a new array you need to use abc=xyz.dup or abc=xyz+[] etc, now they are references to two separate arrays that can be changed independently.

            TIG

            1 Reply Last reply Reply Quote 0
            • B Offline
              ben.doherty
              last edited by

              Thanks chaps. In some odd way I knew that, well, I owned all the bits of information, I just hadn't assembled them yet. I've updated it so that lesson 1 reads better (i.e. no variables)
              I'll go through and check the others now.

              1 Reply Last reply Reply Quote 0
              • honoluludesktopH Offline
                honoluludesktop
                last edited by

                TIG, Thanks.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  dominikh
                  last edited by

                  Saying that Ruby doesn't have variables is plain wrong though. Even if the variables just hold references to objects, they're still variables, and the term "instance variable" is found throughout most object oriented programming languages (and I think the fact that Matz himself calls them variables is proof enough that Ruby has variables :))

                  Of course it might be wrong to compare BASIC variables and Ruby variables, but then it's also wrong to compare apples and oranges.

                  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