<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by TAYAB on Medium]]></title>
        <description><![CDATA[Stories by TAYAB on Medium]]></description>
        <link>https://medium.com/@tayabfarooq009?source=rss-32ccad0cf08b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JyetpNuPW2pHtkKJF2iw1g.jpeg</url>
            <title>Stories by TAYAB on Medium</title>
            <link>https://medium.com/@tayabfarooq009?source=rss-32ccad0cf08b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:52:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tayabfarooq009/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Linked List Insert Operation In Dart]]></title>
            <link>https://medium.com/@tayabfarooq009/linked-list-insert-operation-in-dart-d175e6bad107?source=rss-32ccad0cf08b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d175e6bad107</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[linked-lists]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[TAYAB]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 16:20:02 GMT</pubDate>
            <atom:updated>2023-01-07T16:20:02.033Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WP3hTdkbJ5wemlF0mC08fQ.png" /><figcaption>Linked list</figcaption></figure><p>A linked list is an important data structure in computer science, consisting of a series of interconnected nodes that can be accessed sequentially. Each node in a linked list stores a value and the address of the next node in the chain, creating a linear structure that can hold a collection of values. The first node in a linked list is called the head node, while the last node is known as the tail node. A linked list can be visualized as a chain of rings, each connected to the next in a continuous sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WuBsA4mqRItvvt_pGqtKtQ.png" /><figcaption>Nodes Of Linked List</figcaption></figure><p>The above ring represents two nodes each having its values and the address of the next node. Node ‘A’ has a value of “100” and the address of node ‘B’ while node B has a value of 200 and an address of ‘C’.</p><p>This process continues till the end making a chain-like structure which is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qrrAORwlfISQybrEcgq0uw.png" /></figure><pre>class Node&lt;T&gt; {<br>  T value;<br>  Node&lt;T&gt;? next;<br>  Node({required this.value, this.next});<br><br>  @override<br>  String toString() {<br>    return &#39;$value-&gt; ${next.toString()}&#39;;<br>  }<br>}</pre><p>First, we will start with creating class of type T which is the convention use for generic in dart meaning that it can store any value.</p><p>Terms explanation:</p><p>T value: A variable of type generic which will store the actual content of linked list — a required parameter.</p><p>Node&lt;T&gt;? next: A nullable variable which will point to next node and may be null.</p><p>toString() method: A method that will print the values recursively when the instance is printed.</p><pre>class LinkedList&lt;E&gt; {<br>  Node&lt;E&gt;? head;<br>  Node&lt;E&gt;? tail;<br>  bool get isEmpty =&gt; head == null;<br><br>//First Method<br>  void insertAtStart(E e) {<br>    head = Node(value: e, next: head);<br>    tail ??= head;<br>  }<br><br>//Second Method<br>  void insertAtEnd(E value) {<br>    if (isEmpty) {<br>      insertAtStart(value);<br>      return;<br>    }<br>    tail!.next = Node(value: value);<br>    tail = tail!.next;<br>  }<br><br>//Third Method<br>  Node&lt;E&gt;? nodeAfter(int index) {<br>    var currentNode = head;<br>    var currentIndex = 0;<br><br>    while (currentNode != null &amp;&amp; currentIndex &lt; index) {<br>      currentNode = currentNode.next;<br>      currentIndex += 1;<br>    }<br>    return currentNode;<br>  }<br><br>//Fourth Method<br>  Node&lt;E&gt; insertAfter(Node&lt;E&gt; node, E value) {<br>    if (tail == node) {<br>      insertAtEnd(value);<br>      return tail!;<br>    }<br>    node.next = Node(value: value, next: node.next);<br>    return node.next!;<br>  }<br><br>  @override<br>  String toString() {<br>    if (isEmpty) return &#39;List is Empty&#39;;<br>    return head.toString();<br>  }<br>}<br></pre><p>This code defines a class called LinkedList which is a generic data structure that can hold elements of any type E.</p><p>The LinkedList class has three instance variables:</p><ul><li>head: a reference to the first node in the list</li><li>tail: a reference to the last node in the list</li><li>isEmpty: a getter that returns true if the list is empty, and false otherwise</li></ul><p>The LinkedList class has four methods:</p><ol><li>insertAtStart(E e): This method inserts a new node containing the element e at the beginning of the list. If the list was previously empty, then the head and tail pointers are updated to point to the new node. If the list was not empty, then the next pointer of the new node is set to point to the current head of the list, and the head pointer is updated to point to the new node.</li><li>insertAtEnd(E value): This method inserts a new node containing the element value at the end of the list. If the list is empty, then it calls the insertAtStart method to insert the new node at the beginning of the list. Otherwise, it sets the next pointer of the current tail node to point to the new node, and updates the tail pointer to point to the new node.</li><li>nodeAfter(int index): This method returns a reference to the node in the list that is located at the specified index. It does this by starting at the head of the list, and then iterating through the list until it reaches the desired index. If the index is out of range (i.e. greater than or equal to the number of nodes in the list), then it returns null.</li><li>insertAfter(Node&lt;E&gt; node, E value): This method inserts a new node containing the element value after the specified node node in the list. If node is the current tail of the list, then it calls the insertAtEnd method to insert the new node at the end of the list. Otherwise, it sets the next pointer of the new node to point to the node that was originally after node, and sets the next pointer of node to point to the new node.</li></ol><p>The LinkedList class also has an toString() method which returns a string representation of the list. If the list is empty, it returns the string &quot;List is Empty&quot;. Otherwise, it returns the string representation of the head node, which will recursively include the string representation of the rest of the list.</p><p>Use the following main function to see the output of each method that you have implemented.</p><pre>void main() {<br>  final list = LinkedList&lt;int&gt;();<br>  list.insertAtStart(3);<br>  list.insertAtStart(2);<br>  list.insertAtStart(1);<br>  print(&#39;insert at start: $list&#39;);<br>  list.insertAtEnd(100);<br>  list.insertAtEnd(200);<br>  print(&#39;insert at end: $list&#39;);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*29_49Zq0r0e4pKQlQ8KR2Q.png" /><figcaption>Output of Linked List Operation</figcaption></figure><pre>class Node&lt;T&gt; {<br>  T value;<br>  Node&lt;T&gt;? next;<br>  Node({required this.value, this.next});<br><br>  @override<br>  String toString() {<br>    return &#39;$value-&gt; ${next.toString()}&#39;;<br>  }<br>}<br><br>class LinkedList&lt;E&gt; {<br>  Node&lt;E&gt;? head;<br>  Node&lt;E&gt;? tail;<br>  bool get isEmpty =&gt; head == null;<br><br>//First Method<br>  void insertAtStart(E e) {<br>    head = Node(value: e, next: head);<br>    tail ??= head;<br>  }<br><br>//Second Method<br>  void insertAtEnd(E value) {<br>    if (isEmpty) {<br>      insertAtStart(value);<br>      return;<br>    }<br>    tail!.next = Node(value: value);<br>    tail = tail!.next;<br>  }<br><br>//Third Method<br>  Node&lt;E&gt;? nodeAfter(int index) {<br>    var currentNode = head;<br>    var currentIndex = 0;<br><br>    while (currentNode != null &amp;&amp; currentIndex &lt; index) {<br>      currentNode = currentNode.next;<br>      currentIndex += 1;<br>    }<br>    return currentNode;<br>  }<br><br>//Fourth Method<br>  Node&lt;E&gt; insertAfter(Node&lt;E&gt; node, E value) {<br>    if (tail == node) {<br>      insertAtEnd(value);<br>      return tail!;<br>    }<br>    node.next = Node(value: value, next: node.next);<br>    return node.next!;<br>  }<br><br>  @override<br>  String toString() {<br>    if (isEmpty) return &#39;List is Empty&#39;;<br>    return head.toString();<br>  }<br>}<br><br>void main(List&lt;String&gt; args) {<br>    final list = LinkedList&lt;int&gt;();<br>  list.insertAtStart(3);<br>  list.insertAtStart(2);<br>  list.insertAtStart(1);<br>  print(&#39;Before: $list&#39;);<br>  var middleNode = list.nodeAfter(2)!; //this will insert 42 after node index 1<br>  list.insertAfter(middleNode, 42);<br>  print(&#39;After: $list&#39;);<br>}</pre><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d175e6bad107" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stack Applications & implementation in Dart]]></title>
            <link>https://medium.com/@tayabfarooq009/stack-applications-implementation-in-dart-7707d6b35f69?source=rss-32ccad0cf08b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7707d6b35f69</guid>
            <category><![CDATA[stack]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[stack-in-dart]]></category>
            <dc:creator><![CDATA[TAYAB]]></dc:creator>
            <pubDate>Fri, 02 Dec 2022 17:04:00 GMT</pubDate>
            <atom:updated>2022-12-02T17:04:00.560Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Stack Applications &amp; implementation in Dart</strong></p><p>A stack is a collection of similar things that place the same thing on each other. You keep a collection of your college or university books on top of each other &amp; they appear in the form of a building this is called a stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*uGMcLAgVRaEuwHEAeDvfMA.png" /><figcaption>stack of books</figcaption></figure><p>But in terms of programming, the stack is an abstract data type that places similar elements at top of each other. A stack of integers in a computer can be thought of as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*5_13Iz4jxbQRQRfkScHg9A.png" /><figcaption>A stack of integers</figcaption></figure><p>In stack, you can have “Last in First Out (LIFO)” strategy meaning that data entered recently, will be able to leave first. Because, of this reason, sometimes stack is also called the LIFO data structure.</p><p><strong>Wait, but what is the application of stack? Following are some of the applications of the stack:</strong></p><ul><li>Stack is used for allocating memory to local variables</li><li>Programming languages that support recursion also use the stack for function calls. In this case, if your calls get to infinity it will call stack overflow, and perhaps the developer’s favorite website stack overflow came after this.</li><li>Search and conquer website also uses the stack.</li></ul><p><strong>Implementation</strong></p><p>Create a new project using the “dart create stack” command in your terminal that will create a new dart project for you. Open your bin folder and clear the file inside the bin folder. If you see an error in the lib or test folder remove the code from them as well &amp; you are good to go.</p><p>Here, we define a class with the name Stack &amp; define the list for backup storage. Programmatically, we defined a private field and initialized it to a list of generic data type “E” meaning that you can place any data type in it. These data type includes integers, double, float, character, or your custom data type as well. I recommend writing the code by yourself instead of copying and pasting.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dclass%252520Stack%25253CE%25253E%252520%25257B%25250A%252520%252520final%252520List%25253CE%25253E%252520_storage%25253B%25250A%252520%252520Stack%2528%2529%252520%25253A%252520_storage%252520%25253D%252520%25253CE%25253E%25255B%25255D%25253B%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dclass%25252520Stack%2525253CE%2525253E%25252520%2525257B%2525250A%25252520%25252520final%25252520List%2525253CE%2525253E%25252520_storage%2525253B%2525250A%25252520%25252520Stack%252528%252529%25252520%2525253A%25252520_storage%25252520%2525253D%25252520%2525253CE%2525253E%2525255B%2525255D%2525253B%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c447b4754ef14bdb7671a68dbecc6a47/href">https://medium.com/media/c447b4754ef14bdb7671a68dbecc6a47/href</a></iframe><p>Now, that you have defined backup storage for the stack, let’s override the string method so that it can print the object as a whole. Overriding is the concept in programming where we change the default functionalities of methods. Let’s do that:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252520%252540override%25250A%252520%252520String%252520toString%2528%2529%252520%25257B%25250A%252520%252520%252520%252520return%252520%2527----Top----%25255Cn%2527%25250A%252520%252520%252520%252520%252520%252520%252520%252520%2527%252524%25257B_storage.reversed.join%2528%2527%25255Cn%2527%2529%25257D%2527%25250A%252520%252520%252520%252520%252520%252520%252520%252520%2527%25255Cn----------%2527%25253B%25250A%252520%252520%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252520%25252540override%2525250A%25252520%25252520String%25252520toString%252528%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520return%25252520%252527----Top----%2525255Cn%252527%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527%25252524%2525257B_storage.reversed.join%252528%252527%2525255Cn%252527%252529%2525257D%252527%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527%2525255Cn----------%252527%2525253B%2525250A%25252520%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f821ea386fb5e80e96de06d2dc658fe/href">https://medium.com/media/0f821ea386fb5e80e96de06d2dc658fe/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%25250A%2527%252524%25257B_storage.reversed.join%2528%2527%25255Cn%2527%2529%25257D%2527%25250A%25250A%252520%252520%25250A%252520%252520&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%2525250A%252527%25252524%2525257B_storage.reversed.join%252528%252527%2525255Cn%252527%252529%2525257D%252527%2525250A%2525250A%25252520%25252520%2525250A%25252520%25252520&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca674dba88d81466d53a000a8987cb1c/href">https://medium.com/media/ca674dba88d81466d53a000a8987cb1c/href</a></iframe><p>The above line of the string is called String interpolation in dart where you can print variables along with some new text being added.</p><p>The stack contains two basic functionalities which are the “<strong>push</strong>” and “<strong>pop”</strong> methods, push method takes elements to be added to the stack &amp; pop method removes the last element. Let’s implement the push &amp; pop methods. Add the below two codes to your Stack class.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%25250A%252520%252520void%252520push%2528E%252520element%2529%252520%25253D%25253E%252520_storage.add%2528element%2529%25253B%25250A%25250A%25250A%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%2525250A%25252520%25252520void%25252520push%252528E%25252520element%252529%25252520%2525253D%2525253E%25252520_storage.add%252528element%252529%2525253B%2525250A%2525250A%2525250A%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea43f40f6bc1475ceaf787cedac764eb/href">https://medium.com/media/ea43f40f6bc1475ceaf787cedac764eb/href</a></iframe><p>If you have noticed push method takes the element of type ‘E’ which is generic, meaning that the stack can have any data type.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%25250AE%252520pop%2528%2529%252520%25253D%25253E%252520_storage.removeLast%2528%2529%25253B%25250A%25250A%25250A%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%2525250AE%25252520pop%252528%252529%25252520%2525253D%2525253E%25252520_storage.removeLast%252528%252529%2525253B%2525250A%2525250A%2525250A%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d022e491405d863c17192b3c72156b4/href">https://medium.com/media/0d022e491405d863c17192b3c72156b4/href</a></iframe><p>Inside your bin file creates the main function &amp; till this point your code show looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*iw8nOAUQtQZxtc9CwGwCTQ.png" /><figcaption>complete stack class with the main function</figcaption></figure><p>Now, we are done with the complete implementation let’s test our code. Create an object of class Stack with the name stack(small letter - recommended). Using stack object, access to push method and pass few integers or your favorite data type to test our code. Inside your main add the following code:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%252520%252520final%252520stack%252520%25253D%252520Stack%2528%2529%25253B%25250A%252520%252520stack.push%25281%2529%25253B%25250A%252520%252520stack.push%25282%2529%25253B%25250A%252520%252520stack.push%25283%2529%25253B%25250A%252520%252520stack.push%25284%2529%25253B%25250A%252520%252520stack.push%25285%2529%25253B%25250A%252520%252520print%2528stack%2529%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D4x%26wm%3Dfalse%26code%3D%25252520%25252520final%25252520stack%25252520%2525253D%25252520Stack%252528%252529%2525253B%2525250A%25252520%25252520stack.push%2525281%252529%2525253B%2525250A%25252520%25252520stack.push%2525282%252529%2525253B%2525250A%25252520%25252520stack.push%2525283%252529%2525253B%2525250A%25252520%25252520stack.push%2525284%252529%2525253B%2525250A%25252520%25252520stack.push%2525285%252529%2525253B%2525250A%25252520%25252520print%252528stack%252529%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ff5a475c7a5e645fd96f4af19c890b6/href">https://medium.com/media/2ff5a475c7a5e645fd96f4af19c890b6/href</a></iframe><p>After running your code the output should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wlH80xkoJH_lHoZIVlebjA.png" /><figcaption>Output</figcaption></figure><p>Use a few time pop methods in the same manner &amp; and you will notice the last add data would have been popped. Add the following code exactly below the print statement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*VJXQGsMlPMYBI6YWZ08Kjw.png" /><figcaption>Using pop method</figcaption></figure><p>The output should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7VVkhRjiq2gXs0l3LkkBiw.png" /><figcaption>The final output for pop</figcaption></figure><p>Since Push and Pop always deal with the last number therefore they have constant time complexity that is O(1).</p><p>Congratulation if you stack to this point &amp; I am quite sure you have learned something new.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7707d6b35f69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[List & List Operations in Dart]]></title>
            <link>https://medium.com/@tayabfarooq009/list-list-operations-in-dart-3b77fb6d696b?source=rss-32ccad0cf08b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b77fb6d696b</guid>
            <category><![CDATA[operation-on-list]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[lists]]></category>
            <dc:creator><![CDATA[TAYAB]]></dc:creator>
            <pubDate>Mon, 28 Nov 2022 21:44:41 GMT</pubDate>
            <atom:updated>2022-11-28T21:44:41.663Z</atom:updated>
            <content:encoded><![CDATA[<p>Dart core library comes with primary data types which are called collections. they are List, Sets, and Maps. They are called collections because of their ability to store collection of data. Let&#39;s have look at each one by one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gt_7OgKAgZk7MYeXW2o5mw.png" /></figure><p>Lists:</p><p>List is a collection of data where you can store the sum of data. The list can be generic or data type specific. In a list, data is stored inside square brackets “[]” which is the main identity point of the list.</p><p>Normally, a list is declared as follows:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%252520myList%252520%25253D%252520%25255B21%25252C%25252033.21%25252C%252520%252522Samuel%252522%25252C%252520%2527Saim%2527%25255D%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%25252520myList%25252520%2525253D%25252520%2525255B21%2525252C%2525252033.21%2525252C%25252520%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525255D%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6847b75e3bf4bcfc3f75508c771a848/href">https://medium.com/media/f6847b75e3bf4bcfc3f75508c771a848/href</a></iframe><p>To print a list using the following methods:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%252520myList%252520%25253D%252520%25255B21%25252C%25252033.21%25252C%252520%252522Samuel%252522%25252C%252520%2527Saim%2527%25255D%25253B%25250Avoid%252520main%2528List%25253CString%25253E%252520args%2529%252520%25257B%25250A%252520%252520print%2528myList%2529%25253B%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%25252520myList%25252520%2525253D%25252520%2525255B21%2525252C%2525252033.21%2525252C%25252520%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525255D%2525253B%2525250Avoid%25252520main%252528List%2525253CString%2525253E%25252520args%252529%25252520%2525257B%2525250A%25252520%25252520print%252528myList%252529%2525253B%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fa9d9384a856efe5fb35b6aee70291f/href">https://medium.com/media/7fa9d9384a856efe5fb35b6aee70291f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*15FHeo7xkEEZ6xktujyYXg.png" /><figcaption>list outputs</figcaption></figure><p>But this is not recommended way of writing good codes instead use checks and loops to print the only data inside lists.</p><p>Check if the list is not empty:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%252520myList%252520%25253D%252520%25255B21%25252C%25252033.21%25252C%252520%252522Samuel%252522%25252C%252520%2527Saim%2527%25255D%25253B%25250Avoid%252520main%2528List%25253CString%25253E%252520args%2529%252520%25257B%25250A%252520%252520if%252520%2528myList.isNotEmpty%2529%252520%25257B%25250A%252520%252520%252520%252520print%2528myList%2529%25253B%25250A%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520print%2528%2527List%252520is%252520empty%2521%2527%2529%25253B%25250A%252520%252520%25257D%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%25252520myList%25252520%2525253D%25252520%2525255B21%2525252C%2525252033.21%2525252C%25252520%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525255D%2525253B%2525250Avoid%25252520main%252528List%2525253CString%2525253E%25252520args%252529%25252520%2525257B%2525250A%25252520%25252520if%25252520%252528myList.isNotEmpty%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528myList%252529%2525253B%2525250A%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528%252527List%25252520is%25252520empty%252521%252527%252529%2525253B%2525250A%25252520%25252520%2525257D%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d3f29789fbb88974f007e85871943cd/href">https://medium.com/media/9d3f29789fbb88974f007e85871943cd/href</a></iframe><p>The right way to print any collection is to use loops as follows:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%252520myList%252520%25253D%252520%25255B21%25252C%25252033.21%25252C%252520%252522Samuel%252522%25252C%252520%2527Saim%2527%25255D%25253B%25250Avoid%252520main%2528List%25253CString%25253E%252520args%2529%252520%25257B%25250A%252520%252520if%252520%2528myList.isNotEmpty%2529%252520%25257B%25250A%252520%252520%252520%252520for%252520%2528var%252520item%252520in%252520myList%2529%252520%25257B%25250A%252520%252520%252520%252520%252520%252520print%2528item%2529%25253B%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520print%2528%2527List%252520is%252520empty%2521%2527%2529%25253B%25250A%252520%252520%25257D%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%25252520myList%25252520%2525253D%25252520%2525255B21%2525252C%2525252033.21%2525252C%25252520%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525255D%2525253B%2525250Avoid%25252520main%252528List%2525253CString%2525253E%25252520args%252529%25252520%2525257B%2525250A%25252520%25252520if%25252520%252528myList.isNotEmpty%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520for%25252520%252528var%25252520item%25252520in%25252520myList%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520print%252528item%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528%252527List%25252520is%25252520empty%252521%252527%252529%2525253B%2525250A%25252520%25252520%2525257D%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2134546aa6c09ec51c582f2ea82751e7/href">https://medium.com/media/2134546aa6c09ec51c582f2ea82751e7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*XHLRkngUyfgDzPGs_0BG9A.png" /></figure><p>Now let&#39;s have a look at the different styles of declarations of lists.</p><p>1. Generic List:</p><p>Right after the keyword <strong>“List”</strong> if no data type is specified it will make the list generic, meaning that you can have mixed data inside that list. For example, you can have integers, Strings, float, and other data types as well.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%252520genericList%252520%25253D%252520%25255B21%25252C%25252033.21%25252C%252520%252522Samuel%252522%25252C%252520%2527Saim%2527%25255D%25253B%25250Avoid%252520main%2528List%25253CString%25253E%252520args%2529%252520%25257B%25250A%252520%252520if%252520%2528genericList.isNotEmpty%2529%252520%25257B%25250A%252520%252520%252520%252520for%252520%2528var%252520item%252520in%252520genericList%2529%252520%25257B%25250A%252520%252520%252520%252520%252520%252520print%2528item%2529%25253B%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520print%2528%2527List%252520is%252520empty%2521%2527%2529%25253B%25250A%252520%252520%25257D%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%25252520genericList%25252520%2525253D%25252520%2525255B21%2525252C%2525252033.21%2525252C%25252520%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525255D%2525253B%2525250Avoid%25252520main%252528List%2525253CString%2525253E%25252520args%252529%25252520%2525257B%2525250A%25252520%25252520if%25252520%252528genericList.isNotEmpty%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520for%25252520%252528var%25252520item%25252520in%25252520genericList%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520print%252528item%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528%252527List%25252520is%25252520empty%252521%252527%252529%2525253B%2525250A%25252520%25252520%2525257D%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/34b8f4dbb016881f1302fc9acd92e8c4/href">https://medium.com/media/34b8f4dbb016881f1302fc9acd92e8c4/href</a></iframe><p>1. Data Type Specific:</p><p>Specifying any particular data type e.g. string, integer or float will restrict the whole list to that particular data type.</p><p>In our case, we made a list of strings so we can have string data inside our list.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%25253CString%25253E%252520stringList%252520%25253D%252520%25255B%252522Samuel%252522%25252C%252520%2527Saim%2527%25252C%252520%2527Peer%252520Pond%2527%25252C%252520%2527Lagly%2527%25255D%25253B%25250Avoid%252520main%2528List%25253CString%25253E%252520args%2529%252520%25257B%25250A%252520%252520if%252520%2528stringList.isNotEmpty%2529%252520%25257B%25250A%252520%252520%252520%252520for%252520%2528var%252520item%252520in%252520stringList%2529%252520%25257B%25250A%252520%252520%252520%252520%252520%252520print%2528item%2529%25253B%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520print%2528%2527List%252520is%252520empty%2521%2527%2529%25253B%25250A%252520%252520%25257D%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%2525253CString%2525253E%25252520stringList%25252520%2525253D%25252520%2525255B%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525252C%25252520%252527Peer%25252520Pond%252527%2525252C%25252520%252527Lagly%252527%2525255D%2525253B%2525250Avoid%25252520main%252528List%2525253CString%2525253E%25252520args%252529%25252520%2525257B%2525250A%25252520%25252520if%25252520%252528stringList.isNotEmpty%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520for%25252520%252528var%25252520item%25252520in%25252520stringList%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520print%252528item%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528%252527List%25252520is%25252520empty%252521%252527%252529%2525253B%2525250A%25252520%25252520%2525257D%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/04c3d51bdd789d839da2c92beaedd304/href">https://medium.com/media/04c3d51bdd789d839da2c92beaedd304/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*nQzRcy3tNiHbNcjYS5mJhg.png" /><figcaption>List of String</figcaption></figure><p><strong><em>It’s Important: </em></strong>Putting any other data type like integer will through an error saying that integer can not be placed inside string collections. As you can verify by running the code below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%25253CString%25253E%252520stringList%252520%25253D%252520%25255B100%25252C%25252020.12%25252C%252520%252522Samuel%252522%25252C%252520%2527Saim%2527%25252C%252520%2527Peer%252520Pond%2527%25252C%252520%2527Lagly%2527%25255D%25253B%25250Avoid%252520main%2528List%25253CString%25253E%252520args%2529%252520%25257B%25250A%252520%252520if%252520%2528stringList.isNotEmpty%2529%252520%25257B%25250A%252520%252520%252520%252520for%252520%2528var%252520item%252520in%252520stringList%2529%252520%25257B%25250A%252520%252520%252520%252520%252520%252520print%2528item%2529%25253B%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520print%2528%2527List%252520is%252520empty%2521%2527%2529%25253B%25250A%252520%252520%25257D%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D773.5%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DList%2525253CString%2525253E%25252520stringList%25252520%2525253D%25252520%2525255B100%2525252C%2525252020.12%2525252C%25252520%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525252C%25252520%252527Peer%25252520Pond%252527%2525252C%25252520%252527Lagly%252527%2525255D%2525253B%2525250Avoid%25252520main%252528List%2525253CString%2525253E%25252520args%252529%25252520%2525257B%2525250A%25252520%25252520if%25252520%252528stringList.isNotEmpty%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520for%25252520%252528var%25252520item%25252520in%25252520stringList%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520print%252528item%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528%252527List%25252520is%25252520empty%252521%252527%252529%2525253B%2525250A%25252520%25252520%2525257D%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eecccd3121b330686643eb4d2d63241e/href">https://medium.com/media/eecccd3121b330686643eb4d2d63241e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*q675ybF3EM2rCh4nBPiVkQ.png" /><figcaption>Erroneous code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxIkISzHYpZZPHys9zMKuA.png" /><figcaption>Erroneous output</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D1014%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252F%25252FAdd%252520operation%25250AList%25253CString%25253E%252520stringList%252520%25253D%252520%25255B%252522Samuel%252522%25252C%252520%2527Saim%2527%25252C%252520%2527Peer%252520Pond%2527%25252C%252520%2527Lagly%2527%25255D%25253B%25250Avoid%252520main%2528%2529%252520%25257B%25250A%252520%252520stringList.add%2528%2527Lily%2527%2529%25253B%25250A%252520%252520if%252520%2528stringList.isNotEmpty%2529%252520%25257B%25250A%252520%252520%252520%252520for%252520%2528var%252520item%252520in%252520stringList%2529%252520%25257B%25250A%252520%252520%252520%252520%252520%252520print%2528item%2529%25253B%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520print%2528%2527List%252520is%252520empty%2521%2527%2529%25253B%25250A%252520%252520%25257D%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D1014%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525252F%2525252FAdd%25252520operation%2525250AList%2525253CString%2525253E%25252520stringList%25252520%2525253D%25252520%2525255B%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525252C%25252520%252527Peer%25252520Pond%252527%2525252C%25252520%252527Lagly%252527%2525255D%2525253B%2525250Avoid%25252520main%252528%252529%25252520%2525257B%2525250A%25252520%25252520stringList.add%252528%252527Lily%252527%252529%2525253B%2525250A%25252520%25252520if%25252520%252528stringList.isNotEmpty%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520for%25252520%252528var%25252520item%25252520in%25252520stringList%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520print%252528item%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528%252527List%25252520is%25252520empty%252521%252527%252529%2525253B%2525250A%25252520%25252520%2525257D%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/54c718e3c547c08d8a6c9a469b0fdeb4/href">https://medium.com/media/54c718e3c547c08d8a6c9a469b0fdeb4/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*mqiefpVAf1SEVD0ZTr3Ysw.png" /><figcaption>Add Operation Output</figcaption></figure><p>Reversed Operation:</p><p>Using reversed method will reverse the order of the list completely as shown below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C0%252C0%252C1%2529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D1071%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252F%25252Freversed%252520operation%25250AList%25253CString%25253E%252520stringList%252520%25253D%252520%25255B%252522Samuel%252522%25252C%252520%2527Saim%2527%25252C%252520%2527Peer%252520Pond%2527%25252C%252520%2527Langly%2527%25255D%25253B%25250Avoid%252520main%2528%2529%252520%25257B%25250A%252520%252520final%252520reversedList%252520%25253D%252520stringList.reversed%25253B%25250A%252520%252520if%252520%2528reversedList.isNotEmpty%2529%252520%25257B%25250A%252520%252520%252520%252520for%252520%2528var%252520item%252520in%252520reversedList%2529%252520%25257B%25250A%252520%252520%252520%252520%252520%252520print%2528item%2529%25253B%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520print%2528%2527List%252520is%252520empty%2521%2527%2529%25253B%25250A%252520%252520%25257D%25250A%25257D%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C0%25252C0%25252C1%252529%26t%3D3024-night%26wt%3Dnone%26l%3Ddart%26width%3D1071%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525252F%2525252Freversed%25252520operation%2525250AList%2525253CString%2525253E%25252520stringList%25252520%2525253D%25252520%2525255B%25252522Samuel%25252522%2525252C%25252520%252527Saim%252527%2525252C%25252520%252527Peer%25252520Pond%252527%2525252C%25252520%252527Langly%252527%2525255D%2525253B%2525250Avoid%25252520main%252528%252529%25252520%2525257B%2525250A%25252520%25252520final%25252520reversedList%25252520%2525253D%25252520stringList.reversed%2525253B%2525250A%25252520%25252520if%25252520%252528reversedList.isNotEmpty%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520for%25252520%252528var%25252520item%25252520in%25252520reversedList%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520print%252528item%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520print%252528%252527List%25252520is%25252520empty%252521%252527%252529%2525253B%2525250A%25252520%25252520%2525257D%2525250A%2525257D%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/64289664e38a48cc069df66ea511b209/href">https://medium.com/media/64289664e38a48cc069df66ea511b209/href</a></iframe><p><em>Here we used reversed method on the original list &amp; assigned it to a new variable called reversed list so that we have the updated list.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*QUkwNxHZ2JTT-ZvRLXXvkg.png" /><figcaption>Reversed List</figcaption></figure><p><em>Happy Coding!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b77fb6d696b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>