Pardon the mess, Play My Code is in beta!


sign up - lost password


All common literals you can normally expect are in Quby. Arrays and Hashes are not discussed here, as they have their own sections.


Text is stored using 'strings', and are created by surrounding text using matching double, or single, quotation marks.

myString = "first string"
myString = 'another string'

There is no difference in using single or double quotes, except that you don't have to escape the single or double quote character (depending on which your using).

You can create multi-line text by using the "\n" character, which denotes an end of line.

message = "This is\nmulti-line\ntext."


These are very similar to strings, and are also known as 'atoms' in other languages. They differ from strings because symbols guarantee that two symbols will always refer to the same object.

They are created using the colon symbol, :, followed by number, letters or underscore characters.

aSymbol = :foo
anotherSymbol = :123

The intention is to use symbols where you want to pass in a description of what you want. Very much as an alternative to using constant identifiers.

For example if you have a collection of objects you could categorize them using symbols.

ships = getUnits( :ships )

def getUnits( type )
    if type == :ships
        // return your ships
    else if type == :bullets
        // return your bullets

ships.each() do |ship|
    ship.turn( :right )


Numbers can be declared as:

IntegerNum = 20
DecimalNum = 0.392

Both decimal and integer numbers are the same class of object, Number.

You can also use underscores within numbers as seperators...

million = 1_000_000
nums    = 10_000.234_938

Numbers cannot start with an underscore (as then it would be a variable or method name).

Hexadecimal numbers are supported by using the '0x' prefix (that is 'zero x') in front of a number. This number will then be parsed as a hexadecimal value:

red   = 0xff
green = 0xaa
blue  = 0xEE


Boolean values are denoted using 'true' or 'false', for each value respectively.

aBoolean    = true
anotherBool = false


Finally if you want to hold 'no object', or 'nothing', you use the 'null' value.

noObj = null

Unlike PHP and JavaScript, there is no undefined value in Quby.

See Also