/tutorial/tuple/example2.e
Specman e | 35 lines | 22 code | 5 blank | 8 comment | 0 complexity | c1831ae30b23f350b5c912969140102d MD5 | raw file
1class EXAMPLE2 2 -- 3 -- To start with TUPLE, just compile an run it : 4 -- 5 -- compile -o example2 -boost example2 6 -- 7 8create {ANY} 9 make 10 11feature {ANY} 12 make 13 local 14 my_large_tuple: TUPLE[INTEGER_8, STRING, INTEGER, CHARACTER, STRING, CHARACTER] 15 do 16 -- Creation of a new TUPLE: 17 my_large_tuple := [1, "Two", {INTEGER_32 3}, '4', "Five", '6'] 18 -- Accessing: 19 20 io.put_string("my_large_tuple.count = " + my_large_tuple.count.to_string + ": [" + my_large_tuple.item_1.to_string + ", " + my_large_tuple.item_2 + ", " + my_large_tuple.item_3.to_string + ", " + my_large_tuple.item_4.to_string + ", " + my_large_tuple.item_5 + ", " + my_large_tuple.item_6.to_string + "]%N") 21 -- Writing: 22 my_large_tuple.set_item_1(0) 23 my_large_tuple.set_item_2(Void) 24 my_large_tuple.set_item_3(0) 25 my_large_tuple.set_item_4('0') 26 my_large_tuple.set_item_5(Void) 27 my_large_tuple.set_item_6('0') 28 io.put_string("[ 29 To know more about TUPLEs, have a look at tuple.e file and keep in mind 30 that a TUPLE is not an array ! 31 32 ]") 33 end 34 35end -- class EXAMPLE2