Types
In GoMelan, types are kept simple.
Basic Types
Here is the list of all the types you can find alongside a small example of how to use it.
Char
Chars in GoMelan represent individual characters. You can declare a Char variable and assign a single character to it. Additionally, you can create Char arrays, such as strings.
myChar: Char = 'a';
alphabet: [Char] = "abcdefghijklmnopqrstuvwxyz";
dLetter: Char = alphabet[3]; // dLetter = 'd'Int
Integers in GoMelan are used to represent whole numbers. You can declare Int variables and perform various arithmetic operations on them.
myInt: Int = 42;
result: Int = myInt + 8; // result = 50String
Strings in GoMelan are sequences of characters. You can declare String variables and perform operations like concatenation.
greeting: String = "Hello";
name: String = "GoMelan";
message: String = greeting + ", " + name + "!"; // message = "Hello, GoMelan!"Float
Floats in GoMelan are used to represent decimal numbers. You can declare Float variables and perform various arithmetic operations, including floating-point division.
myFloat: Float = 3.14;
result: Float = myFloat * 2; // result = 6.28Bool
Booleans in GoMelan represent logical values, either true or false. You can use Bool variables in conditional statements and logical operations.
isTrue: Bool = true;
isFalse: Bool = false;
result: Bool = isTrue && isFalse; // result = falseThese are the basic types in GoMelan, providing a foundation for representing characters, integers, strings, floating-point numbers, and boolean values.
Type Conversion
In GoMelan some internal functions allow you to go even further with types. For example, you can convert any String to an Int and vice-versa.
stringToInt("42")
=> 42Last updated
Was this helpful?