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
, Date
, and Output
.
Math.floor(3.15) //= 3 (rounded down) Math.pi() //= 3.1415926535898 File.read('words.txt') //= (contents of 'words.txt' file)
ReferenceAll built-in modules and methods are listed in the Manual.