Get
The Get
function is used to retrieve a value associated with a specific key from an object.
Parameters
The Get
function accepts two parameters:
the first parameter is the object from which to retrieve the value;
the second parameter is the key, which must be a string, corresponding to the value to be retrieved.
Return Value
The Get
function returns the value associated with the specified key within the object.
If the key is not found in the object,
the Get
function will throw an error and will not return any value.
Examples
Let[p, Object[Person, {{"name", "Alice"}, {"age", 30}, {"isStudent", #f}}]];
Get[p, "name"]; (* => "Alice" *)
Get[p, "age"]; (* => 30 *)
Get[p, "isStudent"]; (* => #f *)
Get[p, "other"]; (* Error! *)
GetType
The GetType
function is used to retrieve the type name of an object.
Parameters
The GetType
function accepts only one object parameter.
Return Value
The GetType
function returns a string representing the TypeName
of the given object.
For an object constructed as Object[TypeName, {...}]
, it will return "TypeName"
.
Examples
GetType[Object[A]]; (* => "A" *)
GetType[2]; (* Error! *)
Greater
The Greater
function compares two numbers.
Parameters
The Greater
function requires exactly two parameters,
both of which must be numeric values.
Return Value
For Greater[a, b]
, if ,the function returns #t
; otherwise, it returns #f
.
Examples
Greater[-3, -1]; (* => #f *)
Greater[15.5, 15.4]; (* => #t *)
Greater[-3, -3]; (* => #f *)