Skip to content

Returning self

Nak edited this page Sep 19, 2022 · 3 revisions

Functions returning self is a method known as method chaining. A common syntax that allow you to chain functions together in a single statement, without requiring any variables to store the output.

An example is how you can chain the BitBuffer's write functions:

local buffer = NikNaks.BitBuffer():WriteFloat(1234):WriteLong(1234):WriteSnort(2):Seek(0)

The script above will create a bitbuffer and write a float, long and snort variables and then reset the pointer to 0.

Nik Naks Wiki


Features:

Clone this wiki locally