Soplang Logo
Soplang

Type Conversion

Inspect values with nooc() and convert between integers, floating-point numbers, strings, and booleans.

Type Conversion in Soplang

Soplang provides built-in functions for inspecting types and converting values. Use abn(), jajab(), qoraal(), and bool() for explicit conversions.

nooc() – Inspect a Type

Use nooc() to get the type name of a value.

type_checking.sop

type_checking.sop
door natiijo = nooc(42)         // "abn"
door natiijo2 = nooc("abc")     // "qoraal"
door natiijo3 = nooc(3.14)      // "jajab"

nooc() returns one of these type names:

Valuenooc()
42abn
3.14jajab
"abc"qoraal
run / beenbool
[1, 2]teed
{a: 1} or a class instancewalax
Functionhawl
maranmaran

Type Conversion Functions

The following table shows common conversions:

ConversionFunctionExample
Int → Stringqoraal()qoraal(42)
String → Intabn()abn("123")
Float → Stringqoraal()qoraal(3.14)
String → Floatjajab()jajab("3.14")
Int → Floatjajab()jajab(5)
Float → Intabn()abn(4.9) → 4 (truncates)
Any → Boolbool()bool(1) → run, bool(0) → been

bool() Rules

bool() returns been for 0, 0.0, "", maran, been, an empty list [], an empty object {}, and the strings "false" and "False". All other values produce run, including the string "been".

bool_rules.sop
qor(bool(0))          // been
qor(bool(""))         // been
qor(bool([]))         // been
qor(bool("false"))    // been
qor(bool("salaan"))   // run
qor(bool("been"))     // run

Example

type_conversion_example.sop
// Integer to string
abn int_value = 42
qoraal int_str = qoraal(int_value)
qor("Integer to string: " + int_str + " (Type: " + nooc(int_str) + ")")

// String to decimal
qoraal decimal_string = "3.14159"
jajab converted_decimal = jajab(decimal_string)
qor("String to decimal: " + converted_decimal + " (Type: " + nooc(converted_decimal) + ")")

// Decimal to integer (truncation)
jajab decimal_num = 42.75
abn int_from_decimal = abn(decimal_num)
qor("Decimal to integer (truncation): " + int_from_decimal)

Input from gelin() is a string. Convert it to the type you need before using it in numeric calculations.

On this page