Format and Finding Libraries

Whenever we need to include a library or class we have already written into a project we are currently working on, we will need to add a use statement. A use statement will includes the classes we wish to use. For example, suppose we were writing a program that generates a random number and outputs it to the user. We don't need to write the code to generate a random number because the Quorum standard library already includes a class that does so. The use statement consists of the "use" keyword followed by the full name of the class or library to include. So, to use the random class we would used the following statement:

use Libraries.Compute.Random
One important thing to remember about the use statement is that it must be placed at the top of file. A class definition and action must always come after the list of use statements. In order to find a library in the Quorum standard library we can use code completion if we are offline If we are using Windows or OSX the shortcut is CTRL + SPACE, to find any available library classes. In addition to code completion there is a Quorum Standard Library Reference available.

Random Number Example

A complete solution to the above problem is as follows:

use Libraries.Compute.Random
class Main
     action Main
          Random random
          output random:RandomIntegerBetween(1, 100)
     end
end

Try making a random number

The .all Command

Sometimes we may want to use all of the classes under a given file. For example, suppose we wanted to include all of the classes in "Libraries.Compute", this includes the Random class and other Math related class. We can add all to the end of the use statement to include all of the classes within a file:

use Libraries.Compute.all
class Main
     action Main
          Random random
          Math math
          output random:RandomIntegerBetween(1, 100)
          output math:SquareRoot(6)
     end
end

Try using all libraries in a package

Next Tutorial

In the next tutorial, we will discuss inheritance, which describes how to use the inheritance and polymorphism.