REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 7-Sep-2010 Edit History  

REBOL 3 Functions: to

to  type  spec

Converts to a specified datatype.

Arguments:

type [any-type!] - The datatype or example value

spec [any-type!] - The attributes of the new value

See also:

make  

Description

Every datatype provides a TO method to allow conversions from other datatypes. The to-binary, to-block, and all other to- functions are mezzanine functions that are based on this TO function.

Here are a few examples:

probe to file! "test.r"
%test.r
probe to path! [a b c]
a/b/c

The TO function lets the target datatype be specified as an argument, allowing you to write code such as:

flag: true
value: to either flag [integer!][decimal!] "123"
print value
123

The conversions that are allowed depend on the specific datatype. Some datatypes allow special conversions, such as:

print to integer! false
0
print to integer! true
1
print to logic! 1
true
print to time! 600  ; # of seconds
0:10


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin