Types
These functions allow you to check the type of a value, such as whether it is a number, string, or array. There are also some functions in here for converting between types. See Learn > Language > Types for a broader overview of the types available in Easel.
IsArray
x.IsArray -> boolean
IsArray(x) -> boolean
Returns true if the value is an array, false otherwise.
IsAsset
x.IsAsset -> boolean
IsAsset(x) -> boolean
Returns true if the value is an Asset, false otherwise.
IsAssetArray
x.IsAssetArray -> boolean
IsAssetArray(x) -> boolean
Returns true if the value is an Asset Array, false otherwise.
IsBool
x.IsBool -> boolean
IsBool(x) -> boolean
Returns true if the value is a boolean, false otherwise.
IsCallback
x.IsCallback -> boolean
IsCallback(x) -> boolean
Returns true if the value is a Callback, false otherwise.
IsCategory
x.IsCategory -> boolean
IsCategory(x) -> boolean
Returns true if the value is a Category, false otherwise.
IsColor
x.IsColor -> boolean
IsColor(x) -> boolean
Returns true if the value is a Color, false otherwise.
IsEntity
x.IsEntity -> boolean
IsEntity(x) -> boolean
Returns true if the value is an Entity, false otherwise.
IsFlag
x.IsFlag -> boolean
IsFlag(x) -> boolean
Returns true if the value is a Flag, false otherwise.
IsKeycode
x.IsKeycode -> boolean
IsKeycode(x) -> boolean
Returns true if the value is a Keycode, false otherwise.
IsMap
x.IsMap -> boolean
IsMap(x) -> boolean
Returns true if the value is a Map, false otherwise.
IsNull
x.IsNull -> boolean
IsNull(x) -> boolean
Returns true if the value is null, false otherwise.
IsNullish
x.IsNullish -> boolean
IsNullish(x) -> boolean
Returns true if the value is null or undefined, false otherwise.
IsNum
x.IsNum -> boolean
IsNum(x) -> boolean
Returns true if the value is a Number, false otherwise.
IsPlayer
x.IsPlayer -> boolean
IsPlayer(x) -> boolean
Returns true if the value is a player Entity, false otherwise.
IsRange
x.IsRange -> boolean
IsRange(x) -> boolean
Returns true if the value is a Range, false otherwise.
IsString
x.IsString -> boolean
IsString(x) -> boolean
Returns true if the value is a String, false otherwise.
IsSymbol
x.IsSymbol -> boolean
IsSymbol(x) -> boolean
Returns true if the value is a Symbol, false otherwise.
IsUndefined
x.IsUndefined -> boolean
IsUndefined(x) -> boolean
Returns true if the value is undefined, false otherwise.
IsVector
x.IsVector -> boolean
IsVector(x) -> boolean
Returns true if the value is a Vector, false otherwise.
SymbolName
symbol.SymbolName -> string
SymbolName(symbol) -> string
Returns the name of a Symbol as a String.
Examples:
let x = SymbolName($mySymbol) // x is "mySymbol"
pub symbol Banana
pub fn Example1() {
let x = SymbolName(Banana) // x is the String: "Banana"
}
See also: SymbolFromName, ToSymbol
SymbolFromName
name.SymbolFromName -> string
SymbolFromName(name) -> string
Looks up the Symbol with the given name, or returns undefined if no such Symbol exists.
This is function is the opposite of the SymbolName function.
pub symbol Banana
pub fn Example1() {
let a = SymboLName(Banana) // a is the String: "Banana"
let b = SymbolFromName(a) // b is the Symbol: Banana
}
This is function is the precise opposite of the SymbolName function, which means it works on Symbol names:
- If you use SymbolName on a Symbol, you will get the raw Symbol name, which is a String that does not begin with a
$. That can be used directly with this function. - If you have used ToString on a Symbol, you will get a String that begins with a
$. This function does not strip of the$prefix and so it will not match anything as the$is not part of the Symbol name. See ToSymbol for a more lenient version of this function that will strip off the$prefix.
See also: SymbolName, ToSymbol
ToSymbol
name.ToSymbol -> string
ToSymbol(name) -> string
Converts a String into a Symbol, or returns undefined if no such Symbol exists.
If the String begins with a $, the $ is ignored and the rest of the String is used to look up the Symbol.
This makes it the opposite of the ToString function which will prefix inline symbols with a $.
ToSymbol is a more lenient than the SymbolFromName function, which does not strip off the $.
pub fn Example1() {
let a = ToString($helloWorld) // a is the String: "$helloWorld"
let b = ToSymbol(a) // b is the Symbol: $helloWorld
}