Definitions

From Onix OS Wiki
Jump to: navigation, search

We always have to define things first and then use them. This section will tell you how to define the examples.

Basics

Definition is simple;

def object = something;

Hash

Definition is simple for hashes;

def pyramid = {"x":10, "y":10, "z":10}
pyramid["x"]
=> 10

Array

Definition is simple for arrays;

def triangle = [10,20,30]
triangle[1]
=> 10

Integer

Definition is simple for integers;

def zero = 0
=> 0

String

Definition is simple for strings;

def name = "Oytun"
=> "Oytun"

Functions

Definition is simple for functions;

def sum = fn(x,y){ return x+y; }
sum(10,6)
=> 16

Process

Definition is simple for processes;

proc procname "command" "work path" ["arg1","arg2"]

Socket

Definition is simple for sockets;

sock socketname "type" "port" "ip"