Vector: Difference between revisions

517 bytes added ,  15 April 2019
Describe how to call functions of objects stored in a vector
(+-headings, +-first section: bolding page title)
(Describe how to call functions of objects stored in a vector)
Line 122: Line 122:
     print(item);
     print(item);
}
}
</syntaxhighlight>
== Calling functions using vector objects ==
In order to call functions of objects stored in a vector, you need to refer to the wrapped Nasal vector itself:
<syntaxhighlight lang="nasal">
var object = {
    char: '',
    new: func(char) {
        var objectChild = {parents:[object]};
        objectChild.char = char;
        return objectChild;
    },
    outputInfo: func() {
        print(me.char);
    }
};
var objects = std.Vector.new([object.new('a')]);
objects.vector[0].outputInfo();
</syntaxhighlight>
</syntaxhighlight>
842

edits