Creating your own types

By default Jazz is dynamically typed but you still have the ability to write separate types. For example this is how option looks in standart library:

let __option_proto__ = new(nil)
__option_proto__.is_some = false
__option_proto__.value = nil
__option_proto__.__typename__ = "option" // for typename function
__option_proto__.unwrap = || {
if self.is_some {
} else {
error("Called option.unwrap on a `none` value")
let none = || {
var obj = new(__option_proto__)
let some = |x| {
var obj = new(__option_proto__)
obj.is_some = true
obj.value = x

We got a __option_proto__ object that got 4 fields: is_some,value,__typename__ and unwrap which is function.

How self works? And how to make function that will have self variable?

self initialized when your function is method of object and this function called like this: object1.method() now self is object1 and you can get access to all fields of object1 .