User Tools

Site Tools


eiffel:tuples:example

Example of Eiffel Tuple

     t1: BOOLEAN
		local
			t: TUPLE[age: INTEGER; name: STRING]
			l_age: INTEGER
			l_name: STRING
		do
			comment("t1: Test Tuple")
			create t
			Result := t.age = 0 and t.name = Void
			check Result end
			t := [22, "Mozart"]
			Result := t.age = 22 and t.name ~ "Mozart"
			check Result end
			l_age := t.age
			l_name := t.name
			Result := l_age = 22 and l_name ~ "Mozart"
			check Result end
			if attached {INTEGER} t[1] as ta1
			and attached {STRING} t[2] as ta2 then
				l_age := ta1
				l_name := ta2
			end
			Result := l_age = 22 and l_name ~ "Mozart"
			check Result end
		end
eiffel/tuples/example.txt · Last modified: 2017/02/12 22:33 by jonathan