Skip to main content

Type Utilities

As TinyPanda strictly enforces matching types across operators, these functions allow you to safely cast types at runtime.

str​

Converts an integer, float, or expression into its string representation. This is essential for combining numeric data with text.

bamboo score = 99;
bamboo pi = 3.14;

echo("Your score: " + str(score)); // Outputs: Your score: 99
echoln("Pi value: " + str(pi)); // Outputs: Pi value: 3.14

num​

Converts a valid string containing a numeric literal back into an integer or a float, depending on whether a decimal point is present.

bamboo textDigits = "123";
bamboo textFloat = "45.67";

echoln(num(textDigits) + 7); // Outputs: 130
echoln(num(textFloat) + 0.33); // Outputs: 46.0

whatIs​

Checks the data type of any value, variable, or math calculation and returns it as a text string.

  • Returns: A STRING of the type name (like "INT", "FLOAT", "STRING", "FUNCTION").
// Checking raw values or expressions
whatIs("Hello world!"); // Returns: "STRING"
whatIs(true); // Returns: "BOOLEAN"
whatIs(22 / 7); // Returns: "FLOAT"

// Checking a function block itself
whatIs(fn(){}); // Returns: "FUNCTION"

// Checking the returned execution result of a function
whatIs(fn(){ 100; }()); // Returns: "INTEGER"