/tutorial/tuple/example2.e

http://github.com/tybor/Liberty · Specman e · 35 lines · 22 code · 5 blank · 8 comment · 0 complexity · c1831ae30b23f350b5c912969140102d MD5 · raw file

  1. class EXAMPLE2
  2. --
  3. -- To start with TUPLE, just compile an run it :
  4. --
  5. -- compile -o example2 -boost example2
  6. --
  7. create {ANY}
  8. make
  9. feature {ANY}
  10. make
  11. local
  12. my_large_tuple: TUPLE[INTEGER_8, STRING, INTEGER, CHARACTER, STRING, CHARACTER]
  13. do
  14. -- Creation of a new TUPLE:
  15. my_large_tuple := [1, "Two", {INTEGER_32 3}, '4', "Five", '6']
  16. -- Accessing:
  17. 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")
  18. -- Writing:
  19. my_large_tuple.set_item_1(0)
  20. my_large_tuple.set_item_2(Void)
  21. my_large_tuple.set_item_3(0)
  22. my_large_tuple.set_item_4('0')
  23. my_large_tuple.set_item_5(Void)
  24. my_large_tuple.set_item_6('0')
  25. io.put_string("[
  26. To know more about TUPLEs, have a look at tuple.e file and keep in mind
  27. that a TUPLE is not an array !
  28. ]")
  29. end
  30. end -- class EXAMPLE2