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

    "include" vs "require"

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 245 Views 2 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.
    • N Offline
      NewOne
      last edited by Gábor

      Hy ! It may look like a newbie question - that is it 😄
      But... can somebody explain what is the difference between "include" and "require" statement? Maybe with a simple example to fix this once for ever in my mind.

      Thank you! ☀

      1 Reply Last reply Reply Quote 0
      • tbdT Offline
        tbd
        last edited by

        5 sec search on google -

        What's the difference between "include" and "require" in Ruby?

        Answer:

        The include and require methods do very different things.

        The require method does what include does in most other programming languages: run another file. It also tracks what you've required in the past and won't require the same file twice. To run another file without this added functionality, you can use the load method.

        The include method takes all the methods from another module and includes them into the current module. This is a language-level thing as opposed to a file-level thing as with require. The include method is the primary way to "extend" classes with other modules (usually referred to as mix-ins). For example, if your class defines the method "each", you can include the mixin module Enumerable and it can act as a collection.

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

        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