Tables are the secondary data structures of Mint. A table is a mapping of keys to values. A mapping is similar to a phone book, where the phone numbers are the values and the names are the keys.
Joe Lunabader -> (220) 555-0888 Bill Moonwinnower -> (221) 555-2834 Jessica Ruby -> (221) 555-1396To make a table in Mint, you enclose comma-separated pairs inside square brackets, and surround those with curly braces. myTable = {[17, 900], [8, 9], ["honey butter", "gelatin powder"]}To grab an item from a table, use indexing. print myTable[17] print myTable["honey butter"]Tables are ordered collections of items, so you can also index them like this: print myTable[0] //Prints the first item inside the table. print myTable[1] //Prints the second item inside the table. print myTable[8] //Prints the value 9 bound to the key 8 inside the table.To modify a table, change a certain index to a different pair. myTable[0] = [null, 0] //Changes [17, 19] to [null, 0] myTable[2] = [[], {}] //Points an empty list to an empty tableNull is an empty object that does nothing. It's just a placeholder. Finally, you can also make 1-dimensional tables that act exactly like lists. tbl = {1, 2, 4, 8, "solar panels"} print tbl[2] Previous Lesson: Lists Next Lesson: Data Structures Table of Contents |