<?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 Amit Singh on Medium]]></title>
        <description><![CDATA[Stories by Amit Singh on Medium]]></description>
        <link>https://medium.com/@amitsingh_14780?source=rss-56a2d8db1c7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*sg8cl31Y-WEB8Xafzg5CwQ.jpeg</url>
            <title>Stories by Amit Singh on Medium</title>
            <link>https://medium.com/@amitsingh_14780?source=rss-56a2d8db1c7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 14:43:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amitsingh_14780/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[The Evolution of Artificial Intelligence: A Journey Through Time]]></title>
            <link>https://medium.com/@amitsingh_14780/the-evolution-of-artificial-intelligence-a-journey-through-time-b3937ab8e505?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3937ab8e505</guid>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 19:14:37 GMT</pubDate>
            <atom:updated>2025-04-14T19:14:37.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence (AI) has made extraordinary progress over the last few decades, evolving from theoretical concepts to real-world applications that are changing industries, improving lives, and solving complex problems. This journey has been marked by breakthroughs in technology, fueled by the ingenuity and creativity of researchers and developers. Let’s dive into the key milestones that have shaped the evolution of AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N0TUmM7aVhAxv0M_C8LmPA.png" /></figure><h3>🌟 The Early Years: 1950s to 1970s</h3><p>The idea of AI began to take shape in the mid-20th century, with early pioneers laying the groundwork for future advancements. While primitive by today’s standards, these early developments were instrumental in demonstrating that machines could mimic certain aspects of human intelligence.</p><h3>🔍 Turing Test (1950)</h3><p>One of the most iconic concepts introduced by Alan Turing, the “Turing Test” became the first major attempt to define AI. Turing proposed that a machine could be considered intelligent if it could convince a human interlocutor that it was human through conversation. This laid the foundation for the field of AI, challenging researchers to create machines capable of human-like reasoning.</p><h3>💬 ELIZA (1966)</h3><p>Joseph Weizenbaum’s <strong>ELIZA</strong> was one of the first AI programs capable of simulating human conversation. ELIZA operated as a virtual psychotherapist, engaging users in simple text-based interactions. While basic by today’s standards, ELIZA showcased AI’s potential to interact with humans in a meaningful way.</p><h3>🧱 SHRDLU (1970)</h3><p>Developed by Terry Winograd, <strong>SHRDLU</strong> was an early natural language processing (NLP) program that could understand and execute commands in a virtual world of blocks. It showed that AI could interpret instructions and perform tasks based on user input, a crucial leap forward in human-computer interaction.</p><h3>📊 Statistical Methods Take Over: 1980s to 1990s</h3><p>As AI research progressed, systems moved from being rule-based to learning from data, enabling more sophisticated models. The 1980s and 1990s saw AI evolve from symbolic logic to statistical methods, greatly enhancing its capabilities.</p><h3>📉 Rule-Based Systems vs. Statistical Models</h3><p>During this period, researchers realized the limitations of rule-based systems and began to explore statistical models that could learn from data. This shift made AI more adaptable and capable of handling uncertainty, opening the door to a variety of applications in fields like computer vision and speech recognition.</p><h3>🔬 The Machine Learning Revolution: 2000s and Beyond</h3><p>The 21st century brought the rise of <strong>Machine Learning</strong> (ML), especially deep learning, a subfield of ML that revolutionized AI. With the ability to learn from massive datasets, ML systems began to outperform traditional rule-based systems in many domains.</p><h3>🧠 Deep Learning (2006)</h3><p>The introduction of <strong>deep learning</strong> marked a pivotal moment in AI history. Deep learning models, built on neural networks with many layers, allowed machines to learn from vast amounts of data, transforming fields like image recognition, natural language processing, and autonomous driving.</p><h3>🔠 Word2Vec (2013)</h3><p>The <strong>Word2Vec</strong> algorithm, developed by Google, represented a breakthrough in natural language processing. It allowed machines to understand the meaning of words in context, revolutionizing NLP and improving tasks like translation, sentiment analysis, and content generation.</p><h3>💬 Attention Mechanisms (2014)</h3><p>The introduction of <strong>attention mechanisms</strong> allowed models to focus on the most relevant parts of a sequence when making predictions. This was particularly useful in machine translation and speech recognition, improving the accuracy and fluidity of AI systems.</p><h3>🎯 BERT (2018)</h3><p>Google’s <strong>BERT</strong> (Bidirectional Encoder Representations from Transformers) model brought a new level of understanding to AI systems. By analyzing language bidirectionally, BERT set new benchmarks in NLP tasks, including question answering, sentiment analysis, and more.</p><h3>🚀 The Rise of GPT: 2020 to Present</h3><p>In recent years, <strong>Generative Pre-trained Transformers (GPT)</strong> have taken AI to new heights. OpenAI’s GPT models, particularly GPT-3, have demonstrated an unprecedented ability to generate human-like text, sparking excitement and innovation in the field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6gzslfMqhF-npFvstOakVg.png" /></figure><h3>🤖 GPT-3 (2020)</h3><p>OpenAI’s <strong>GPT-3</strong> became a game-changer in natural language generation. With 175 billion parameters, GPT-3 was capable of generating highly coherent and contextually relevant text, performing tasks ranging from creative writing to complex problem-solving.</p><h3>🔍 GPT-3.5 (2022)</h3><p>GPT-3.5 improved upon the original GPT-3, offering better accuracy and handling of more complex queries. This version refined GPT-3’s capabilities, making it a more powerful tool for businesses, researchers, and developers.</p><h3>🧠 GPT-4 (2023)</h3><p>With <strong>GPT-4</strong>, OpenAI set new standards for AI understanding and text generation. GPT-4 offered deeper reasoning, better contextual understanding, and enhanced capabilities in handling nuanced language.</p><h3>🚀 GPT-5: A Glimpse into the Future</h3><p>Looking ahead, <strong>GPT-5</strong> is on the horizon, promising even more powerful and versatile AI capabilities. Expected to be released soon, GPT-5 will introduce several advancements that will shape the next era of AI.</p><h3>🌍 Unified Model</h3><p>One of the most exciting features of GPT-5 is its unified model, which combines the best elements of the GPT and o-series models into a single, more efficient system. This will streamline the user experience and enhance AI’s capabilities across different applications.</p><h3>📸 Multimodal Processing</h3><p>GPT-5 will expand its capabilities to include better <strong>multimodal processing</strong>, meaning it will not only handle text but also images, video, and possibly audio. This will open up new possibilities for interactive and immersive AI experiences.</p><h3>🧠 Advanced Reasoning and Problem Solving</h3><p>GPT-5 will take AI’s reasoning and problem-solving abilities to the next level. This includes improved logical thinking, advanced mathematical capabilities, and better performance in tasks that require critical thinking and creativity.</p><h3>📅 Release Timeline</h3><p>Though the exact release date is still under wraps, GPT-5 is expected to launch in the coming months, following OpenAI’s release of GPT-4.5, also known as <strong>Orion</strong>. The anticipation for GPT-5 reflects the continued excitement and optimism surrounding AI’s potential.</p><h3>The Road Ahead: What’s Next for AI?</h3><p>AI has already achieved remarkable milestones, but we are just scratching the surface of its potential. As we look to the future, we can expect more breakthroughs in AI models, natural language understanding, machine learning, and beyond. The future of AI is incredibly exciting, with new possibilities emerging every day.</p><p>From healthcare to entertainment, from education to autonomous systems, the applications of AI are endless. With each new development, we move closer to an era where AI systems can think, reason, and interact with the world in ways that mimic human cognition.</p><p>Stay tuned, because the future of AI is just beginning, and we are all part of this incredible journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3937ab8e505" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Activation Functions in Neural Networks — Why ReLU Isn’t Always Enough]]></title>
            <link>https://medium.com/@amitsingh_14780/activation-functions-in-neural-networks-why-relu-isnt-always-enough-2791673bfb13?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2791673bfb13</guid>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 12:05:28 GMT</pubDate>
            <atom:updated>2025-04-15T10:53:35.318Z</atom:updated>
            <content:encoded><![CDATA[<h3>🔊 Activation Functions in Neural Networks Part 2— Why ReLU Isn’t Always Enough</h3><p>When you’re just starting with neural networks, it’s easy to overlook how critical <strong>activation functions</strong> are. They’re more than just mathematical formulas — they determine how your model learns, adapts, and performs.</p><p>In this article, we’ll dive into:</p><ul><li>What activation functions are</li><li>Why they matter in deep learning</li><li>Popular activation functions and their use cases</li><li>When to use each (with visuals)</li></ul><h3>🔄 What Is an Activation Function?</h3><p>An <strong>activation function</strong> decides whether a neuron should be activated or not by applying a transformation to its input. It introduces <strong>non-linearity</strong> into the model, allowing it to learn complex patterns.</p><p>If you removed activation functions from a neural network, it would simply behave like a linear regression model — no matter how many layers you add.</p><h3>📈 Why Are They Important?</h3><ul><li><strong>Non-linearity</strong>: Models real-world complexities</li><li><strong>Backpropagation</strong>: Allows gradients to flow and weights to update</li><li><strong>Output control</strong>: Helps produce probabilities or specific output ranges</li></ul><h3>📊 Popular Activation Functions and Their Use Cases</h3><h3>1. ✨ ReLU (Rectified Linear Unit)</h3><p><strong>Formula</strong>: f(x) = max(0, x)</p><ul><li><strong>Use in</strong>: Hidden layers of most deep networks</li><li><strong>Pros</strong>: Fast, simple, sparse activation, avoids vanishing gradient</li><li><strong>Cons</strong>: Can “die” during training (outputs become zero permanently)</li></ul><h3>2. ⚡ Leaky ReLU / Parametric ReLU</h3><p><strong>Formula</strong>: f(x) = x if x &gt; 0 else αx (e.g., α=0.01)</p><ul><li><strong>Use in</strong>: Deep networks when ReLU causes dead neurons</li><li><strong>Pros</strong>: Fixes ReLU’s dying neuron issue</li><li><strong>Cons</strong>: Slightly more complex, needs tuning</li></ul><h3>3. 🪡 Sigmoid</h3><p><strong>Formula</strong>: f(x) = 1 / (1 + e^(-x))</p><ul><li><strong>Use in</strong>: Output layer of binary classification problems</li><li><strong>Pros</strong>: Outputs between 0 and 1 (ideal for probabilities)</li><li><strong>Cons</strong>: Vanishing gradients, not zero-centered</li></ul><h3>4. 🌊 Tanh</h3><p><strong>Formula</strong>: f(x) = (e^x - e^-x) / (e^x + e^-x)</p><ul><li><strong>Use in</strong>: Hidden layers of shallow or recurrent networks</li><li><strong>Pros</strong>: Zero-centered output, smoother than sigmoid</li><li><strong>Cons</strong>: Still suffers from vanishing gradients</li></ul><h3>5. 📊 Softmax</h3><p><strong>Formula</strong>: f(x_i) = e^(x_i) / Σ e^(x_j)</p><ul><li><strong>Use in</strong>: Output layer of multiclass classification problems</li><li><strong>Pros</strong>: Converts raw scores to probabilities</li><li><strong>Cons</strong>: Requires more computation, sensitive to large inputs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7AykFVvV8-3A7s7CGDAcw.png" /></figure><h3>🔢 When Should You Use Which?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zsCbCgKPs7T4xxzEySRumA.png" /></figure><h3>🌐 Visualizing the Functions</h3><p>Visual plots help you see how each activation transforms input. (Use graphs of each function: sigmoid, tanh, relu, leaky relu, softmax)</p><h3>💡 Final Thoughts</h3><p>ReLU may be the most popular choice, but it’s not always the best. Each activation function has its strengths and weaknesses, and choosing the right one can significantly impact your model’s performance.</p><p>As you experiment and build deeper models, keep these functions in mind. Activation isn’t just a technical detail — it’s the switch that powers learning.</p><p><em>Follow for more insights on AI, machine learning, and practical guides for building smarter models!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2791673bfb13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Understanding Neural Networks: A Beginner’s Guide to the Brains Behind AI]]></title>
            <link>https://medium.com/@amitsingh_14780/understanding-neural-networks-a-beginners-guide-to-the-brains-behind-ai-a6da58df9494?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6da58df9494</guid>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Thu, 27 Mar 2025 20:10:44 GMT</pubDate>
            <atom:updated>2025-04-15T10:53:54.825Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 Understanding Neural Networks Part 1: A Beginner’s Guide to the Brains Behind AI</h3><p>Artificial Intelligence is transforming the world around us — from voice assistants and recommendation systems to self-driving cars and medical diagnostics. At the heart of many of these breakthroughs lies a powerful concept: <strong>Neural Networks</strong>.</p><p>But what exactly is a neural network? And why is it such a big deal in the world of machine learning? Let’s break it down.</p><h3>🧐 What Is a Neural Network?</h3><p>A <strong>Neural Network</strong> is a machine learning model inspired by how the human brain works. It’s designed to recognize patterns and relationships in data, making it ideal for tasks like image recognition, speech processing, and predictive analytics.</p><p>Think of it as a web of interconnected “neurons” (nodes), where each connection has a weight and each neuron performs a simple computation. When combined, they’re capable of learning complex functions.</p><h3>🧹 The Basic Building Blocks</h3><h3>1. Neurons (Nodes)</h3><p>Each neuron takes inputs, performs a weighted sum, applies an activation function, and passes the output forward.</p><h3>2. Layers</h3><ul><li><strong>Input Layer</strong>: Where the data enters.</li><li><strong>Hidden Layers</strong>: Where the magic happens. These layers extract and learn features.</li><li><strong>Output Layer</strong>: Where predictions are made.</li></ul><h3>3. Weights and Biases</h3><ul><li><strong>Weights</strong> determine the importance of each input.</li><li><strong>Bias</strong> helps shift the activation function to better fit the data.</li></ul><h3>⚙️ How It Learns: The Training Process</h3><p>Neural networks learn through a process called <strong>backpropagation</strong>:</p><ol><li><strong>Forward Propagation</strong>: Data moves from input to output, generating predictions.</li><li><strong>Loss Calculation</strong>: The error (loss) is calculated by comparing the output to the true result.</li><li><strong>Backpropagation</strong>: The network adjusts weights using optimization (like Gradient Descent) to minimize the error.</li><li>Repeat over multiple iterations (epochs) until the network learns the best representation.</li></ol><h3>🌐 Why Neural Networks Are Powerful</h3><ul><li><strong>Non-linearity</strong>: They can model complex, non-linear relationships in data.</li><li><strong>Scalability</strong>: With enough data and layers, they can solve highly complex tasks.</li><li><strong>Generalization</strong>: Well-trained networks can make accurate predictions on new, unseen data.</li></ul><h3>🔍 Real-World Applications</h3><ul><li><strong>Image Recognition</strong>: Detecting faces, objects, or medical anomalies.</li><li><strong>Natural Language Processing (NLP)</strong>: Powering chatbots, translators, and sentiment analysis.</li><li><strong>Finance</strong>: Fraud detection and market forecasting.</li><li><strong>Healthcare</strong>: Diagnosing diseases from X-rays or MRIs.</li><li><strong>Autonomous Vehicles</strong>: Understanding surroundings through sensor data.</li></ul><h3>🚀 Popular Types of Neural Networks</h3><p>Type Use Case <strong>Feedforward Neural Network (FNN)</strong> Basic prediction tasks <strong>Convolutional Neural Network (CNN)</strong> Image and video processing <strong>Recurrent Neural Network (RNN)</strong> Sequence data like time series or language <strong>LSTM / GRU</strong> Long-term dependencies in sequences <strong>Transformer</strong> State-of-the-art NLP (used in ChatGPT, BERT, etc.)</p><h3>🧠 But It’s Not All Magic</h3><p>Neural Networks are powerful, but they come with challenges:</p><ul><li>Require lots of data</li><li>Can overfit easily</li><li>Hard to interpret (“black-box”)</li><li>Computationally expensive</li></ul><p>That’s why data preprocessing, model selection, and evaluation are critical parts of any deep learning project.</p><h3>💡 Final Thoughts</h3><p>Neural Networks are more than just a buzzword — they’re the foundation of modern AI. As tools, libraries, and hardware continue to evolve, their capabilities will only expand.</p><p>Whether you’re a data scientist, developer, or tech enthusiast, understanding how neural networks work is key to navigating the AI-driven future.</p><p><em>Thanks for reading! If you enjoyed this article, feel free to clap, share, or follow for more on AI, machine learning, and tech trends.</em> 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6da58df9494" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hashable Protocol in Swift]]></title>
            <link>https://medium.com/@amitsingh_14780/hashable-protocol-in-swift-650a7d9d9aeb?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/650a7d9d9aeb</guid>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 19:18:50 GMT</pubDate>
            <atom:updated>2020-06-02T19:18:50.393Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fiImGXYIpwHpk5GXr-q-Lw.jpeg" /></figure><p>When we have to use custom type in sets or the dictionary key. We must have to confirm the <strong>Hashable</strong> protocol. What is that and why swift language forces us to confirm it?</p><p>The dictionary data type contains keys and value and it ensures that the keys are unique. Same for the Set. all the elements inside the Set should be unique. That’s why if we need to use custom type inside the Set or key in the Dictionary they should confirm the hashable protocol. In this article, we are going to discuss the Hashing, Hasher, Hash value, Hashable protocol.</p><h3>What is Hashing</h3><p>Generally, Hashing is a term that applies an algorithm to the data to convert it to a value. Please open your playground and run the below example.</p><blockquote><strong>let</strong> hashDict : Dictionary = [“firstname” : “John”]</blockquote><blockquote><strong>let</strong> hashvalue = hashDict[“firstname”].hashValue</blockquote><blockquote>print(hashvalue)</blockquote><p>Output:</p><blockquote><strong>6801508033489910158</strong></blockquote><p>When you run above code again and again you’ll see that hash value changing every time.</p><p>Congratulation! you just know about <strong>Hash value or Hashes. </strong>The Hash value can be a positive and negative integer value generated by using the hash function.</p><figure><img alt="Congratulation! you just know about Hash value." src="https://cdn-images-1.medium.com/max/500/1*zoTV56cSlEiVyVyAQAhLkQ.gif" /></figure><p>And the Algorithm function that applied to the data to get value is called the <strong>Hash function or Hasher. </strong>The below example is describing how the Hashing works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*0cGX1X9xnrGBpbhYu8b4gg.png" /><figcaption>Hashing Process</figcaption></figure><p>The standard universal hash function uses a pre-execution random 128-bit seed value, making hash values less predictable.</p><p>More specifically, the universal hash function used in the Swift standard library is <a href="https://github.com/attaswift/SipHash">SipHash</a>. Which was originally designed by Jean-Philippe Aumasson and Daniel J. Bernstein in 2012.</p><h4>Why Hashing is important</h4><p>Hashing provides constant-time search, insert and delete operations on average. This is why hashing is one of the most used data structures, example problems are, <a href="https://www.geeksforgeeks.org/print-distinct-elements-given-integer-array/">distinct elements</a>, counting frequencies of items, finding duplicates, etc. Hashing reduces the complexity of code processing.</p><h3>Hashable protocol</h3><p>Before any discussion please go to the playground and run below code.</p><blockquote><strong>struct</strong> animal{</blockquote><blockquote><strong>var</strong> name : String</blockquote><blockquote><strong>var</strong> age : String</blockquote><blockquote>}</blockquote><blockquote><strong>let</strong> hashDict = [animal : String]()</blockquote><p>you’ll see that Xcode is giving an error<strong><em> “Referencing initializer ‘init()’ on ‘Dictionary’ requires that ‘animal’ conform to ‘Hashable’”</em></strong></p><p>It means that we need to confirm the hashable protocol. Let’s read the apple documentation.</p><blockquote>To use your own custom type in a set or as the key type of a dictionary, add Hashable conformance to your type. The Hashable protocol inherits from the Equatable protocol, so you must also satisfy that protocol’s requirements.</blockquote><p>let’s confirm Hashable protocol to above code</p><blockquote><strong>struct</strong> animal : Hashable{</blockquote><blockquote><strong>var</strong> name : String</blockquote><blockquote><strong>var</strong> age : String</blockquote><blockquote>}</blockquote><blockquote><strong>let</strong> hashDict = [animal : String]()</blockquote><p><em>Now you’ll see the error has been gone.</em></p><p>You can use any type that conforms to the protocol in a set or as a dictionary key. Many types in the standard library conform to Hashable: Strings, integers, floating-point, and Boolean values, and even sets are hashable by default.</p><p>The compiler automatically synthesizes your custom type’s Hashable and requirements when you declare Hashable conformance in the type’s original declaration and your type meets these criteria:</p><ul><li>For a struct, all its stored properties must conform to Hashable.</li><li>For an enum, all its associated values must conform to Hashable. (An enum without associated values has Hashable conformance even without the declaration.)</li></ul><p>To customize your type’s Hashable conformance, to adopt Hashable in a type that doesn’t meet the criteria listed above, or to extend an existing type to conform to Hashable, implement the hash(into:) the method in your custom type.</p><p>In your hash(into:) implementation, call combine(_:) on the provided Hasher instance with the essential components of your type. To ensure that your type meets the semantic requirements of the Hashable and Equatable protocols, it’s a good idea to also customize your type’s Equatable conformance to match.</p><p>Let’s take an example</p><blockquote><strong>struct</strong> GridPoint {</blockquote><blockquote><strong>var</strong> x: Int</blockquote><blockquote><strong>var</strong> y: Int</blockquote><blockquote>}</blockquote><p>Here is the structure of the grid points that the user will tap. What if you only need newly-tapped grid points.</p><p>then we can confirm hashable protocol on the extension here</p><blockquote><strong>extension</strong> GridPoint: Hashable {</blockquote><blockquote><strong>static</strong> <strong>func</strong> == (lhs: GridPoint, rhs: GridPoint) -&gt; Bool {</blockquote><blockquote><strong>return</strong> lhs.x == rhs.x &amp;&amp; lhs.y == rhs.y</blockquote><blockquote>}</blockquote><blockquote><strong>func</strong> hash(into hasher: <strong>inout</strong> Hasher) {</blockquote><blockquote>hasher.combine(x)</blockquote><blockquote>hasher.combine(y)</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>The hash(into:) method in this example feeds the grid point’s x and y properties into the provided hasher. These properties are the same ones used to test for equality in the == operator function.</p><blockquote><strong>var</strong> tappedPoints: Set = [GridPoint(x: 2, y: 3), GridPoint(x: 4, y: 1)]</blockquote><blockquote><strong>let</strong> nextTap = GridPoint(x: 0, y: 1)</blockquote><blockquote><strong>if</strong> tappedPoints.contains(nextTap) {</blockquote><blockquote>print(“Already tapped at (\(nextTap.x), \(nextTap.y)).”)</blockquote><blockquote>} <strong>else</strong> {</blockquote><blockquote>tappedPoints.insert(nextTap)</blockquote><blockquote>print(“New tap detected at (\(nextTap.x), \(nextTap.y)).”)</blockquote><blockquote>}</blockquote><blockquote>// Prints “New tap detected at (0, 1).”)</blockquote><h4>Conclusion</h4><p>So that’s it for the hashable protocol for more detail you can check the apple documentation as well.</p><p><a href="https://developer.apple.com/documentation/swift/hashable">Hashable | Apple Developer Documentation</a></p><p>Eat_Sleep_Work, Bye Bye</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=650a7d9d9aeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Application Security & Tips]]></title>
            <link>https://medium.com/@amitsingh_14780/application-security-tips-788b8afb5f33?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/788b8afb5f33</guid>
            <category><![CDATA[ios-application-security]]></category>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Mon, 25 May 2020 20:31:01 GMT</pubDate>
            <atom:updated>2020-05-29T20:36:48.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2Jt8uSAQ43S_eXUnHN2kw.jpeg" /></figure><blockquote>Hey Guys, Today we are going to discuss application security. Present time, is the most common fear for all the users/clients. Is their application data secure?</blockquote><blockquote>In this article, we are going to discuss the pointers for both iOS and Android Applications.</blockquote><h3>Save Data on a secure place</h3><p>Most of the applications are using the wrong data storage to save their private data. In iOS approximate 80% of applications are using the User default to save their data inside the app.</p><p>Generally, the developer used user default for saving the user data like email, Phone number, UserID/Accesstoken, Crypto keys, etc. So, guys, you are making the biggest mistake when you are choosing user default to save user private data because using a third party mac application without even having to Jailbreak your device, you can easily view <strong>UserDefaults</strong> data for any app downloaded from the AppStore. you can increase your iOS security by this link.</p><p>For the <strong>Android</strong> same I will recommend using Internal storage on the place of shared preferences. Because you know that the Android phone is less secure than iOS.</p><h3>Prevent Man in the Middle Attack</h3><p>What is Man in the Middle attack? It also is known as a <strong>hijack attack </strong>is an attack where the attacker secretly relays and possibly alters the communications between two parties who believe that they are directly communicating with each other. Please check the below image it’s describing the <em>Man in the Middle attack</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*Q8g09wGpQUTvk1XbKXkNtg.png" /></figure><p>So if the man in the middle attack happens to the connection then user privacy can compromise eg. user passwords, important documents, important messages, etc.</p><p>So the solution of the Man in Middle attack is SSL pinning. SSL stands for the <strong>Secure socket layer </strong>and it makes sure that the client is communicating to the right server and the server is communicating to the right client. Below are the tasks for which SSL is responsible.</p><blockquote>How will keys be exchange</blockquote><blockquote>How will data be encrypted</blockquote><blockquote>How will messages be marked as authentic?</blockquote><p>SSL certificate contains a key pair that has Public and private keys. These keys work together to establish an encrypted connection. The certificate also contains the <em>“Subject”</em> which is the identity of Certificate/Website owner.</p><h3>Take care of Secret Keys when pushing the code to the repository</h3><p>Guys This can be possible that it is not a permanent solution but I have written this point according to my observation.</p><p>When we talk about storing the secret keys on <strong>Git</strong> so, many developers can say that they’re storing API keys on their private <strong>Git </strong>repositories. You are aware of the public repo that is not secure at all, anyone can download the code and run at their system. But there is some risk on the private repo as well.</p><p>Private Git repositories hosted on services such as GitHub, GitLab, and Bitbucket are exposed to a different type of risk. When you integrate a third-party application with one of the services mentioned, you may be opening your private repositories to those third parties. Those applications will be able to access your private repositories and read the information contained within. So the attacker can find your sensitive data from it.</p><p>Let’s talk about the solutions</p><blockquote>You can obfuscate the secret keys</blockquote><blockquote>you can use <a href="https://github.com/StackExchange/blackbox">BlackBox</a> is a tool created by the <em>Stack overflow</em> community is the best tool to encrypt small strings. BlackBox is a robust tool as it works with Git as well.</blockquote><blockquote>There are multiple tools on Git as well like <a href="https://git-secret.io/">Git secret</a> and <a href="https://www.agwa.name/projects/git-crypt/">Git-crypt</a></blockquote><h3>Beware of the Third-Party Integration</h3><p>Present time if we face any problem related to the project we generally check on the internet if any third party available to expedite the task. Adding a third party is not the wrong thing. But please make sure that the third party is not taking your personal data and it is 100% secure. Don’t ever disable <a href="https://www.jobscan.co/blog/what-is-an-applicant-tracking-system/">ATS</a> for them, even if they ask politely.</p><h3>Prevent Jailbreaking</h3><p>As you know, the attackers can easily jailbreak any application by installing free software on their laptops by downloading the app from Appstore or Playstore.</p><p>For preventing Jailbreak in the application we need to check if the device is jailbroken or not if the device is jailbroken then we can not allow our application to install on that device. It can impact on application <em>userbase.</em></p><p>There will be multiple advantages of detecting devices on Jailbroken. hackers will not able to access your sensitive data from within your application. If you really want an extra layer of security then I would suggest you implement it on your app. Or if you are developing an application for your client you should ask him before implementing it.</p><h3><strong>Session Handling</strong></h3><p>The application server sends back the session token on successful authentication with the mobile application. These session tokens are used by the mobile applications to request for services. If these session tokens remain active for a longer duration and adversaries obtain them via malware or theft, the user account can be hijacked. So presently you can check if you are not using the application long time then it will automatically log out and you have to log in again. Multiple applications automatically logged out even you are an active user.</p><h3><strong>Binary Protections</strong></h3><p>Mobile application source code is available to everyone. An attacker can reverse engineer the application and insert venomous code components and recompile them. If these applications are installed by a user, their data can be theft, become victims of unintended actions, and so on. Most of the applications do not ship with mechanisms such as checksum controls, which help in deducing whether the application has tampered or not. we should have to take care of some <a href="https://www.dionach.com/blog/android-binary-protection-methods/"><strong>pointers</strong></a> at the time of writing the code so that we can prevent our code of reverse Engineering and code tampering. We can also use Proguard for <a href="https://www.perfomatix.com/proguard-android/">Android</a> Application</p><h3>Conclusion</h3><p>We need to take care of the above pointers to ensure that our application has a security layer.</p><p>There can be more pointers that can increase more security of the applications for that you can read <a href="https://subscription.packtpub.com/book/application_development/9781785883378/1/ch01lvl1sec14/owasp-mobile-top-10-risks">OWASP mobile top 10 risks</a>.</p><p>Bye-Bye! Eat, Sleep, and Work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=788b8afb5f33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unknown Facts of Swift functions Part2]]></title>
            <link>https://medium.com/@amitsingh_14780/unknown-facts-of-swift-functions-part2-6b1f0eaed288?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b1f0eaed288</guid>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Wed, 13 May 2020 20:08:34 GMT</pubDate>
            <atom:updated>2020-05-13T20:08:34.916Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*jEIJWzqeJns6_Fr4l2vJQA.jpeg" /></figure><p>Welcome Again Geeks, On the Last session, we have learned about the <em>In-Out Parameters </em>and this is the second part of Unknown Facts of swift functions. If you haven’t read that article then please go and get aware of <a href="https://medium.com/@amitsingh_14780/unknown-facts-of-swift-functions-part1-4f1c373d0a1f"><strong><em>In-out</em></strong></a> <strong>parameter</strong>.</p><p>In this tutorial, We are going to learn about <strong><em>Function Types. </em></strong>So If we’ll talk about the Types in swift. we’ll find that there are two types i.e</p><p><strong>Named types</strong></p><p><strong>Compound types</strong></p><p>According to Swift documentation. A <strong>N<em>amed type</em></strong> is a type that can be given a particular name when it’s defined. OK let’s understand it by another definition. <strong><em>Named Types</em></strong> are those which are defined and identified by the <em>name</em> that they’re given. Classes, structs, enums, and protocols fit this category of Type. for example, the user also defined the name are</p><blockquote><strong>class</strong> SwiftClassType{}</blockquote><blockquote><strong>struct</strong> SwiftStucType{}</blockquote><p><strong><em>Swift standard library defines</em></strong><em> also defines many commonly used named types, including those that represent </em><strong><em>arrays, dictionaries, and optional values.</em></strong></p><p><strong>C<em>ompound types</em></strong> are the types without a name, They have signatures that defines and identifies them as a Type. There are two compound types: <em>function types</em> and <em>Tuple types.</em></p><h3>Function Type</h3><p>We have already discussed that the function types are known by ‘signature’ so let’s see what can be the <em>signatures</em> of function types:</p><blockquote><em>(parameter type) -&gt; return type</em></blockquote><p>So above you can see the signature of the Function type, Hope you are understanding it if not, then let’s discuss it more.</p><blockquote>Rather than writing a paragraph to describe the function types, it will be more convenient to indicate a type of real-time notation.</blockquote><p>Let’s say you are writing a function for getting the marks of 3 subjects of Students to provide the average.</p><blockquote>func average(english: Int, maths: Int, science: Int)-&gt; Int{</blockquote><blockquote>let average = (english + maths + science)/3</blockquote><blockquote>return average</blockquote><blockquote>}</blockquote><p>So the function type of above function will be</p><blockquote>( Int, Int, Int ) -&gt; Int</blockquote><p>So what I have done to get the function type. I just removed the “<strong>english</strong>”, “<strong>maths</strong>”, “<strong>science</strong>” from the function and function name “<strong>average</strong>” from the function declaration. And found the <strong>“Signature”.</strong></p><p><em>“It also can be read as the function has 3 parameters all are Int types, and return the Int value”</em></p><p>What if a function has no parameter and no value?</p><blockquote>func Hello(){</blockquote><blockquote>print(“Hello”)</blockquote><blockquote>}</blockquote><p>Yes! you got it, the signature of this function is</p><blockquote>() -&gt; Void</blockquote><p><em>Because it has no parameter and it’s not returning any value. so if any function is not returning a value it’s void type.</em></p><h3>Let’s know the Use of Function Type</h3><p>So now you have understood the function type but how can we use it? we can declare a function type like a constant or a variable</p><p>For Example,</p><blockquote><strong>var</strong> claculateAverage : (Int,Int,Int)-&gt;Int = average</blockquote><p>You can understand this as “Declared a variable called <strong><em>claculateAverage</em></strong> which has a type of function that contains 3 integer types parameter and return an integer value. this variable refers to a function called average.”</p><p>Let’s use this variable</p><blockquote>print(claculateAverage(5,7,8))</blockquote><p>please stop reading this Article and try declaring this function type variable on your playground and tell me, it is running or not.</p><blockquote>Is it run successfully?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*A5t29FfkdPzNkqJvVWI5PQ.gif" /></figure><p>Do a clap for yourself you’ve just learned how to declare and use <em>Function type.</em></p><h3><strong><em>Function type as a parameter</em></strong></h3><p>We can use function type as a parameter in a function. So try that <strong><em>claculateAverage</em></strong> function type variable as a parameter type in a function.</p><blockquote>func totalAverage(claculateAverage : (Int,Int,Int)-&gt;Int, english: Int, maths: Int, science: Int){</blockquote><blockquote>print(claculateAverage(english, maths, science))</blockquote><blockquote>}</blockquote><p>Here I have declared a function called <strong><em>totalAverage</em></strong><em> </em>that contains 4 parameters the first parameter is a type of (Int, Int, Int)-&gt;Int. You can pass any function of that type as the argument for this first parameter.</p><p>now call this function</p><blockquote>totalAverage(claculateAverage: average, english: 5, maths: 7, science: 8)</blockquote><p>Here I have used <strong><em>average</em></strong> function as a first parameter. Again try to use and run this code.</p><p>Congratulations! You’ve taken a deep dive into Types in swift. In 3 min. of reading. Try some examples of function type yourself to be very good at it <strong>Keep Coding!</strong>.</p><p>Bye-Bye! Eat, Sleep, and Work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b1f0eaed288" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unknown Fact’s of Swift functions Part1]]></title>
            <link>https://medium.com/@amitsingh_14780/unknown-facts-of-swift-functions-part1-4f1c373d0a1f?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f1c373d0a1f</guid>
            <category><![CDATA[swift-function]]></category>
            <category><![CDATA[mita]]></category>
            <category><![CDATA[facts]]></category>
            <category><![CDATA[in-out-parameters]]></category>
            <category><![CDATA[unknown]]></category>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Mon, 11 May 2020 15:15:57 GMT</pubDate>
            <atom:updated>2020-05-12T18:21:12.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*jEIJWzqeJns6_Fr4l2vJQA.jpeg" /></figure><p>Guys, In this article I’m going to tell you about some unknown feature’s of S<em>wift</em> Functions</p><h4>1. In-Out Parameters</h4><h4>2. Function Types</h4><p>Recently, I was working on a task on that, I received a use-case where I need to change the parameter of a function. When I tried it, I got a compile-time error. So it means you can not change the value of the parameter by mistake. if we want to do that we have to use the In-Out parameter.</p><p>let’s try this use-case without the in-out parameter</p><blockquote><strong>func</strong> addFuction(a: Int, b : Int){</blockquote><blockquote>a = 5</blockquote><blockquote>b= 6</blockquote><blockquote>}</blockquote><p>if you’ll run the above program on the playground, you will get an error check the below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*48f_6H2YxyIIt63g8aEoXw.png" /></figure><p>So here you can see the error is <strong><em>Cannot assign to value: ‘a’ is a ‘let’ constant.</em></strong></p><p>Now let’s understand what is In-out parameters and how it works. According to the Apple documentation, the syntax of In-out parameters is</p><blockquote><strong>func</strong> functionName( parameter: <strong>inout</strong> Int) {</blockquote><blockquote>}</blockquote><p>the above code is explaining that if you add an <strong><em>inout</em></strong> keyword before the parameter datatype, you will be able to change the parameter value.</p><p>Let’s try it on the playground. so now the code is</p><blockquote><strong>func</strong> addFunction(a : <strong>inout</strong> Int, b : Int){</blockquote><blockquote>a = 5</blockquote><blockquote>}</blockquote><p>and here is the screenshot of the playground</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*4Q7_hJphbesEXZlkRKGCRg.png" /></figure><p>So please try it by yourself. And you’ll see that error has been gone. <strong><em>So here’s a question: How will you call this function?</em></strong></p><p>The answer is for calling the function you need to add an ampersand with the value. Please see the code snippet below.</p><blockquote><strong>func</strong> addFunction(a : <strong>inout</strong> Int, b : Int){</blockquote><blockquote>a = 5</blockquote><blockquote>}</blockquote><blockquote><strong>var</strong> value = 10</blockquote><blockquote>addFuction(a: &amp;value ,b: 6)</blockquote><p>Please try it by yourself</p><p>Here you have learned the In-Out Parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*zoTV56cSlEiVyVyAQAhLkQ.gif" /></figure><p>So, Guys, That’s it for part 1. In Part 2 we’ll be going to learn about the Function types and how functions are different from the clouser.</p><p><strong><em>Bye-Bye. Eat, Sleep and Code</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f1c373d0a1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn the Basics and develop a project of RXSwift in 15 min]]></title>
            <link>https://medium.com/@amitsingh_14780/learn-the-basics-and-develop-a-project-of-rxswift-in-15-min-4a4e45559b3f?source=rss-56a2d8db1c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a4e45559b3f</guid>
            <category><![CDATA[rxswift]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[rxcocoa]]></category>
            <dc:creator><![CDATA[Amit Singh]]></dc:creator>
            <pubDate>Thu, 09 Apr 2020 13:08:15 GMT</pubDate>
            <atom:updated>2020-04-09T15:06:31.113Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*uXMEAdC4AH7uG9JQjjXxUg.png" /></figure><p><em>Let say if you have to set the things up so the code reflects changes automatically. It means code should have to do exactly what you want. that’s Great!</em></p><p>Swift language has many ways to listen to the changes. However, you must tell the system when something changes. You can get it through <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html">Key-Value Observation</a> and using didSet, but it can be heavy to Handle. Alternatively, We can achieve it by <strong>Reactive</strong> <strong>Programming </strong>as well</p><p><strong>Reactive Programming</strong> is <strong>programming</strong> with asynchronous data streams. When using <strong>reactive programming</strong>, data streams are going to be the spine of your application. Events, messages, calls, and even failures are going to be conveyed by a data stream.</p><p>Have you Understood? Even not me.</p><p>Let’s read this</p><p><strong>Reactive Programming</strong> focuses on asynchronous data streams, which you can listen to and react accordingly. there are several frameworks in Swift that facilitate reactive programming <strong>RxSwift</strong><em> and </em><strong>RxCocoa</strong><em>.</em></p><p><strong><em>RxSwift</em></strong> is a framework for interacting with the Swift programming language, while <strong><em>RxCocoa</em></strong> is a framework that makes Cocoa APIs used in iOS and OS X easier to use with reactive techniques</p><h3>Observable</h3><p>Your smartphone is <strong><em>observable</em></strong>. It <strong><em>emits signals</em> </strong>like Instagram, Facebook notifications, messages, Snapchat notifications and so on. You are naturally <strong><em>subscribed</em></strong> to it, so you get every notification on your home screen. You can now decide what to do with that <strong><em>signal</em></strong>. You are an <em>o</em><strong><em>bserver</em></strong>.</p><p>Now we all are ready to understand the example.</p><p>Please download the <a href="https://drive.google.com/file/d/1ROfvY9D4gtasZgbXzg7CdygG6KGCR2NM/view?usp=sharing">starter code</a> here.</p><p><strong>Please run the code and you will get these two screens</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*vv6b2ZSg45e-ucS5UpdD5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*LTVUlDKXcY9EkFBHS4jImw.png" /></figure><p>Let me take you inside the code what it will do. It will pick one of the Indian vegetables and show you on the initial page. You can see 2 view controllers</p><p><strong>ViewController:</strong> Initial view controller in which you will see the output.</p><p><strong>PickVegetables:</strong> Here you will select one of the vegetables. You will be seeing the table view setup Data source and cell etc.</p><p>But now how you are planning to take get the vegetable total cost selected by the user to the initial screen?</p><p>For that, we are going to use reactive programming. There are two more classes <strong>RXSingleton</strong> and <strong>VegetableModel</strong>. In <strong>RxSingleton</strong> class I have set up a variable that is <strong>veg</strong></p><blockquote><strong>class Rxsingeleton{</strong></blockquote><blockquote><strong>static let singeleton = Rxsingeleton()</strong></blockquote><blockquote><strong>let veg : BehaviorRelay&lt;[Vegetable]&gt; = BehaviorRelay(value: [])</strong></blockquote><blockquote><strong>}</strong></blockquote><p>its type is <strong>BehaviourRelay </strong>please check the following Subjects of RxSwift programming. Ok so select <strong>BehaviourRelay </strong>and check it’s the definition then please see what I found.</p><blockquote><strong>/// BehaviorRelay is a wrapper for `BehaviorSubject`.</strong></blockquote><blockquote><strong>///</strong></blockquote><blockquote><strong>/// Unlike `BehaviorSubject` it can’t terminate with error or completed.</strong></blockquote><blockquote><strong>public final class BehaviorRelay&lt;Element&gt;: ObservableType {</strong></blockquote><blockquote><strong>}</strong></blockquote><h3>Subjects</h3><p>A Subject is a special form of an Observable Sequence, you can subscribe and dynamically add elements to it.</p><p><strong>PublishSubject:</strong></p><p>If you subscribe to it you will get all the events that will happen after you subscribed.</p><p><strong>BehaviourSubject:</strong></p><p>A behavior subject will give any subscriber the most recent element and everything that is emitted by that sequence after the subscription happened.</p><p><strong>ReplaySubject:</strong></p><p>If you want to replay more than the most recent element to new subscribers on the initial subscription you need to use a ReplaySubject. With a ReplaySubject, you can define how many recent items you want to emit to new subscribers.</p><p><strong>Variable: </strong>A Variable is just a <em>BehaviourSubject</em> wrapper that feels more natural to none reactive programmers. It can be used as a normal Variable.</p><p>OK, hope you understand the Subject if not then I will explain all the subject in detail in my next blog.</p><p>Please go to the Viewcontroller class there you will find the below code.</p><blockquote><strong>func getVegetablecost(){</strong></blockquote><blockquote><strong>_ = subj.veg.asObservable().subscribe(onNext: { (veg) in</strong></blockquote><blockquote><strong>})</strong></blockquote><blockquote><strong>}</strong></blockquote><p>In this method, we have subscribed to the <strong>veg</strong> variable to get notified when there will be any change happen with the <strong>veg</strong> variable. And there Is one more function that calculating the cost of selected vegetables.</p><p>Please add calculate cost function to your ViewController class</p><blockquote><strong>func calculateCost(veg : [Vegetable]){</strong></blockquote><blockquote><strong>let totalPrice = veg.reduce(0) { (result, next) -&gt; Float in</strong></blockquote><blockquote><strong>return result + next.price</strong></blockquote><blockquote><strong>}</strong></blockquote><blockquote><strong>counterLabel.text = “Total cost of selected vegetable =&gt; \(totalPrice)”</strong></blockquote><blockquote><strong>}</strong></blockquote><p>Please go to the PickVegetables class and add the below code to did select function.</p><blockquote><strong>let newValue = subj.veg.value + [Vegetable.India[indexPath.row]]</strong></blockquote><blockquote><strong>subj.veg.accept(newValue)</strong></blockquote><p>So now you are ready to get the total cost of selected vegetables by reactive programming please run the project and select the vegetable to get the cost.</p><p>Please find the <a href="https://drive.google.com/file/d/1tcTTElcweONC7y3zhAZ9K5H596znNAwA/view?usp=sharing">final code</a> below</p><p>What next?</p><p><em>In the next tutorial, we will be covering all the </em><strong><em>Subjects</em></strong><em> in detail and how we can implement table view data source and delegate by using Reactive Programming.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a4e45559b3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>