-
Notifications
You must be signed in to change notification settings - Fork 3
/
syntax.tiny
executable file
·69 lines (59 loc) · 1012 Bytes
/
syntax.tiny
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Import an external module
import io
# All prim datatypes
let i as int
let s as short
let b as byte
let f as float
let f as int array[10]
# All builtin class utils
let str as string
let lst as list of int
let bx as box of int
let f as file
# Create a new class
class Cat
{
# Give it attribs
public readonly name as string
public weight as int
# Define the constructor
constructor(string name, int weight)
{
self.name = name
self.weight = weight
}
# Define a method
public method print()
{
io.log("Cat")
io.log("Name: ", name)
io.log("Weight: ", weight)
}
}
# Template class
class Template of T
{
x as T array[10]
index as int
}
# Defining return types
func add(int a, int b) -> int
{
return a + b
}
func set_cat_weight(Cat ref cat)
{
cat.weight = 69
}
# Main function is where things start
func main()
{
# Let will make a new variable and auto it's type
let x = "testing"
io.log(x)
# Create a new object
cat = new Cat("Bob", 21)
set_cat_weight(ref cat)
cat.print()
}