Methods
Methods are functions that are attached to a variable.
All built-in data types (Strings, Lists, etc.) have their own methods.
Use the dot .
operator to call a method.
$text = 'Tipsy Turtle' $text.contains('Turtle') //= true $text.length() //= 12 (includes spaces)
Methods can be chained together.
$text = 'I see a Tarantula.' $yell = $text.upperCase().replace('.', '!!!') //= 'I SEE A TARANTULA!!!'
Modules
A module is a bundle of functions that are related to each other.
THT comes with essential modules like Math
, File
, and Input
.
Math.pi() //= 3.1415926535898 File.read('words.txt') //= (contents of 'words.txt' file) Input.get('sort') //= (value of the 'sort' parameter in the URL)
ReferenceAll built-in modules and methods are listed in the Manual.