Real life example of List,Tuple,Set and Map

You can use a List to store the steps necessary to cook a chicken, because Lists support sequential access and you can access the steps in order.

You can use a Tuple to store the latitude and longitude of your home, because a tuple always has a predefined number of elements (in this specific example, two). The same Tuple type can be used to store the coordinates of other locations.

You can use a Set to store passport numbers, because a Set enforces uniqueness among its elements. Passport numbers are always unique and two people can’t have the same one.

You can use a Map to convert a list of Imperial/US measurements to their Metric (SI) equivalents because a Map takes a list and applies an operation to each member of the list and returns a new list ( )

Browse More Popular Posts

Leave a Comment