|
![]() |
||||||||||||||
Record TutorialRecordRecord is structured data type consisted of name-value pairs. While single record may consist of elements of different types, the type of each element is fixed. Record data type is written as Record[<name1>:<el1-type>, <name2>:<el2-type>, ..., <namen>:<eln-type>]. Record literals begin by { and end by }, with elements separated by commas or semicolons. Record may not be empty. Braces are used not only for literal record specification, but also as a record construction operator. Several records are presented in the following example, with their types described in comments. Source code:// Record[ // fst: Record[a:Integer], // scd: Record[i:Integer, // s: String, // trd:Record[nme:String, lst:List[Integer]]] // ] { fst: { a:1 }, scd: { i:1, s:'a', trd:{ nme:'list', lst:[1,2,3] }} } Result:{ fst:{ a:1 }; scd:{ i:1; s:"a"; trd:{ lst:[1,2,3]; nme:"list" } } }
|
|
||||||||||||||
© 2006 Saša Malkov | |||||||||||||||