/tutorial/tuple/example1.e
Specman e | 43 lines | 31 code | 4 blank | 8 comment | 0 complexity | c3b4101507fd045ffe8eafa7ea6f40b6 MD5 | raw file
1class EXAMPLE1 2 -- 3 -- To start with TUPLE, just compile an run it : 4 -- 5 -- compile -o example1 -boost example1 6 -- 7 8create {ANY} 9 make 10 11feature {ANY} 12 make 13 local 14 my_tuple: TUPLE[INTEGER_8, STRING, REAL] 15 do 16 -- Creation of a new TUPLE: 17 my_tuple := [2, "Lucien", 6.5] -- Accessing: 18 io.put_string("my_tuple.count = ") 19 io.put_integer(my_tuple.count) 20 io.put_string("%Nmy_tuple.item_1 = ") 21 io.put_integer(my_tuple.item_1) 22 io.put_string("%Nmy_tuple.item_2 = ") 23 io.put_string(my_tuple.item_2) 24 io.put_string("%Nmy_tuple.item_3 = ") 25 io.put_real(my_tuple.item_3) 26 -- Writing: 27 my_tuple.set_item_1(3) 28 my_tuple.set_item_2("Marie") 29 my_tuple.set_item_3(4.5) 30 -- Accessing: 31 io.put_string("%Nmy_tuple.item_1 = ") 32 io.put_integer(my_tuple.item_1) 33 io.put_string("%Nmy_tuple.item_2 = ") 34 io.put_string(my_tuple.item_2) 35 io.put_string("%Nmy_tuple.item_3 = ") 36 io.put_real(my_tuple.item_3) 37 io.put_string("[ 38 To know more about TUPLEs, have a look at example #2. 39 40 ]") 41 end 42 43end -- class EXAMPLE1