up: DYN     index Zimbu documentation

CLASS T.dyn @public

summary

     

The builtin type dyn.

This is dynamically typed, it can hold a value of any type.

$ToString() string @public  Return a string representation for the value.
$ToString(format) string @public  Return a formatted string representation for the value.
$Type() type @public  Return the type of the value.
$Size() int @public  Return the size of the dyn.
$Compare(other) int @public  Return -1 when other sorts after this dyn, zero when other is equal to this dyn, and 1 when other sorts before this dyn.
$Equal(other) bool @public  Return TRUE when other is equal to this dyn, FALSE otherwise.
 
 

members (alphabetically)

     

FUNC $Compare(dyn other) int @public

     

Return -1 when other sorts after this dyn, zero when other is equal to this dyn, and 1 when other sorts before this dyn.

This works like with < and > operators, for similar types the value is used. This especially matters for numbers.

When using ?.Compare() on a NIL dyn and other is NIL it returns zero. When other is not NIL it returns -1.

FUNC $Equal(dyn other) bool @public

     

Return TRUE when other is equal to this dyn, FALSE otherwise.

This works like with == and != operators, for similar types the value is used. This especially matters for numbers.

 int i = 8
 dyn xi = i
 float f = 8.0
 dyn xf = f
 IO.print(xi.Equal(xf))  # prints TRUE
 IO.print(xi == xf)      # prints TRUE

When using ?.Compare() on a NIL dyn and other is NIL it returns TRUE. Otherwise when other is NIL returns FALSE.

FUNC $Size() int @public

     

Return the size of the dyn.

This calls Size() on the item contained in the dyn.

A NIL dyn also returns zero, it does not throw an E.NilAccess exception.

FUNC $ToString() string @public

     

Return a string representation for the value.

This uses the ToString() method of the actual type. If there is no ToString() method the type of the value is returned surrounded by dashes. E.g. "-object-".

 dyn x = getAnX()
 IO.print("The value of x is " .. x.ToString())

FUNC $ToString(string format) string @public

     

Return a formatted string representation for the value.

This uses the ToString(format) method of the actual type. If there is no ToString(format) method the type of the value is returned surrounded by dashes. E.g. "-object-".

 dyn x = getAnX()
 IO.print("The value of x is " .. x.ToString())

FUNC $Type() type @public

     

Return the type of the value.

 dyn x = getAnX()
 IO.print("The type of x is " .. x.Type().ToString())

license

      Copyright 2013 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0