<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rahul Dahal</title>
    <description>The latest articles on DEV Community by Rahul Dahal (@rahuldahal).</description>
    <link>https://dev.to/rahuldahal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F480824%2Fe7304a10-a95d-4fd9-9c2f-94c79d68bd8b.jpeg</url>
      <title>DEV Community: Rahul Dahal</title>
      <link>https://dev.to/rahuldahal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rahuldahal"/>
    <language>en</language>
    <item>
      <title>[Resolved] MongoDB Atlas line-break issue</title>
      <dc:creator>Rahul Dahal</dc:creator>
      <pubDate>Tue, 01 Jun 2021 03:33:57 +0000</pubDate>
      <link>https://dev.to/rahuldahal/resolved-mongodb-atlas-line-break-issue-33a5</link>
      <guid>https://dev.to/rahuldahal/resolved-mongodb-atlas-line-break-issue-33a5</guid>
      <description>&lt;h1&gt;
  
  
  The context
&lt;/h1&gt;

&lt;p&gt;While creating &lt;a href="https://mynoteit.herokuapp.com" rel="noopener noreferrer"&gt;this&lt;/a&gt; PWA, I wanted to store the &lt;em&gt;markdown&lt;/em&gt; data into the MongoDB's &lt;a href="https://www.mongodb.com/cloud/atlas" rel="noopener noreferrer"&gt;Atlas&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Markdown&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Some interesting title&lt;/span&gt;
Description about the topic...
&lt;span class="p"&gt;
-&lt;/span&gt; list #1
&lt;span class="p"&gt;-&lt;/span&gt; list #2
&lt;span class="gt"&gt;
&amp;gt; Maybe a quote ?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above markdown would be stored as a &lt;strong&gt;single string&lt;/strong&gt; in the database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// other fields&lt;/span&gt;
  &lt;span class="nl"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;# Some interesting title&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Description about the topic...&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;- list #1&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;- list #2&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt; Maybe a quote ?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="c1"&gt;// further fields&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  The problem
&lt;/h1&gt;

&lt;p&gt;While reading the data from the &lt;a href="https://www.mongodb.com/cloud/atlas" rel="noopener noreferrer"&gt;Atlas&lt;/a&gt;, the line-break escape character, i.e. &lt;code&gt;\n&lt;/code&gt; would come as already escaped, i.e. &lt;code&gt;\\n&lt;/code&gt; &lt;strong&gt;notice the double '\'&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Therefore, while parsing it as &lt;em&gt;HTML&lt;/em&gt;, the &lt;strong&gt;line-break&lt;/strong&gt; wouldn't be read as a line-break character but a literal &lt;em&gt;\n&lt;/em&gt; character.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rendered HTML&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr9145c0srdckpb11chax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr9145c0srdckpb11chax.png" alt="Unexpected Render of Markdown"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Markdown parser(&lt;a href="https://marked.js.org/" rel="noopener noreferrer"&gt;marked.js&lt;/a&gt;) expects a line-break between each block(headings, lists, paragraphs, quotes, etc) to render them as expected. Otherwise, it will render them as a single line of string.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In the example above, it renders everything as a heading level 1.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why ?
&lt;/h2&gt;

&lt;p&gt;When the Markdown parser sees &lt;code&gt;#&lt;/code&gt; token, it assumes that the text after it(until a line-break) is to be rendered as a H₁. Thus, everything including lists, paragraphs, quotes are rendered as &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; because of no line-break.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Solution
&lt;/h1&gt;

&lt;p&gt;I made a mistake by thinking that the problem was with the &lt;em&gt;Markdown parser,&lt;/em&gt; while instead the problem was with the &lt;strong&gt;data&lt;/strong&gt; coming from MongoDB.&lt;/p&gt;

&lt;p&gt;The doubly escaped character &lt;code&gt;\\n&lt;/code&gt; was the culprit.&lt;/p&gt;

&lt;p&gt;As a workaround, I tried to &lt;em&gt;replace&lt;/em&gt; all &lt;code&gt;\\n&lt;/code&gt;s with &lt;code&gt;\n&lt;/code&gt;s  from the markdown string before passing it to the &lt;a href="https://marked.js.org/" rel="noopener noreferrer"&gt;Markdown Parser&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;parser&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;marked&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 'markdownString' would be the markdown field read from mongodb&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;replacedWithSingleEscape&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;markdownString&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="sr"&gt;n/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;replacedWithSingleEscape&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Solved! This is how the rendered output would look like after the fix&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8mefwctfjk9u3hcq3kfj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8mefwctfjk9u3hcq3kfj.png" alt="Expected Render of Markdown"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>Save Hash Links for Future Reference.</title>
      <dc:creator>Rahul Dahal</dc:creator>
      <pubDate>Mon, 18 Jan 2021 14:39:17 +0000</pubDate>
      <link>https://dev.to/rahuldahal/save-hash-links-for-future-reference-54fa</link>
      <guid>https://dev.to/rahuldahal/save-hash-links-for-future-reference-54fa</guid>
      <description>&lt;h2&gt;
  
  
  The Context
&lt;/h2&gt;

&lt;p&gt;I was reading an amazing article about &lt;a href="https://github.com/ryanmcdermott/clean-code-javascript"&gt;JavaScript Best Practices&lt;/a&gt;. &lt;br&gt;&lt;br&gt;
While going through it, there were some &lt;strong&gt;points&lt;/strong&gt; that I found really useful and productive. &lt;br&gt;&lt;br&gt;
I wanted to &lt;strong&gt;save&lt;/strong&gt; those points, which in turn would make it easier for me to &lt;strong&gt;reference&lt;/strong&gt; back in the future. &lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Birth of SaveHash
&lt;/h2&gt;

&lt;p&gt;As a solution to my problem mentioned above, I created SaveHash.&lt;br&gt;
SaveHash makes it easier for readers to &lt;strong&gt;save&lt;/strong&gt; &lt;em&gt;hash&lt;/em&gt;(#) links and refer back to it in the future. &lt;br&gt;&lt;br&gt;
&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/savehash/"&gt;Get It Here&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Here is the Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xXXgpaPT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://res.cloudinary.com/rdaahal/image/upload/v1609770198/saveHash/saveHash_demo_mpx0f3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xXXgpaPT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://res.cloudinary.com/rdaahal/image/upload/v1609770198/saveHash/saveHash_demo_mpx0f3.gif" alt="Demo GIF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The extension workflow looks like this,
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b4PXREGa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wqftditfwna8ug5danaw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b4PXREGa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wqftditfwna8ug5danaw.png" alt="SaveHash extension workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  This project is OpenSource.
&lt;/h3&gt;

&lt;p&gt;Feel free to contribute by following &lt;a href="https://github.com/rahuldahal/save-hash/blob/master/CONTRIBUTING.md"&gt;this&lt;/a&gt; guide..&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>github</category>
    </item>
    <item>
      <title>FootballStats</title>
      <dc:creator>Rahul Dahal</dc:creator>
      <pubDate>Sat, 26 Dec 2020 12:35:38 +0000</pubDate>
      <link>https://dev.to/rahuldahal/footballstats-35h9</link>
      <guid>https://dev.to/rahuldahal/footballstats-35h9</guid>
      <description>&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;A React app that consumes a &lt;a href="https://www.football-data.org/"&gt;third party API&lt;/a&gt; to provide the League Standings, Top Scorers and Upcoming Matches for top 5 football leagues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category Submission:
&lt;/h3&gt;

&lt;p&gt;Program for People &lt;/p&gt;

&lt;h3&gt;
  
  
  App Link
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://footballstats.tk"&gt;footballStats&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ETPuJaBN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/son018887tp4p9asodhd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ETPuJaBN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/son018887tp4p9asodhd.png" alt="Bundesliga Match day 14 2020-2021"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iwJl6ENF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hwo9kexq3p218z8itqd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iwJl6ENF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hwo9kexq3p218z8itqd7.png" alt="Premier League Standings, match day 15"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A Single Page React app.&lt;/li&gt;
&lt;li&gt;Consumes a &lt;a href="https://www.football-data.org/"&gt;third party API&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Uses &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"&gt;service-worker&lt;/a&gt; for caching and push notifications.&lt;/li&gt;
&lt;li&gt;Is installable as a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps"&gt;PWA&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Link to Source Code
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/rahuldahal/football-stats"&gt;GitHub Repo&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Permissive License
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R4p9mjzs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/github/license/rahuldahal/football-stats" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R4p9mjzs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.shields.io/github/license/rahuldahal/football-stats" alt="MIT"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Always wanted to create an app related to &lt;em&gt;football&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Built to &lt;strong&gt;strengthen&lt;/strong&gt; my portfolio.&lt;/li&gt;
&lt;li&gt;Learned how to think in terms of &lt;strong&gt;components&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Learned about &lt;strong&gt;service-workers&lt;/strong&gt; and &lt;strong&gt;PWA&lt;/strong&gt; in general.&lt;/li&gt;
&lt;li&gt;Learned the &lt;strong&gt;ReactJS&lt;/strong&gt; workflow and tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How I built it
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I actually had already built a similar app, without any library/framework.&lt;/li&gt;
&lt;li&gt;Rebuilt that app with &lt;strong&gt;ReactJS&lt;/strong&gt; from &lt;em&gt;scratch&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Picked up knowledge relating to offline-first and PWAs.&lt;/li&gt;
&lt;li&gt;Used &lt;a href="https://netlify.com"&gt;Netlify&lt;/a&gt; to build and host the site.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Additional Resources/Info
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://vanilla.footballstats.tk"&gt;Vanilla JS version of the app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rahuldahal.com.np"&gt;Personal Portfolio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/rahuldahal"&gt;GitHub Profile&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dohackathon</category>
    </item>
    <item>
      <title>Commenting out the Comment ?</title>
      <dc:creator>Rahul Dahal</dc:creator>
      <pubDate>Wed, 28 Oct 2020 13:04:54 +0000</pubDate>
      <link>https://dev.to/rahuldahal/commenting-out-the-comment-2j62</link>
      <guid>https://dev.to/rahuldahal/commenting-out-the-comment-2j62</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Disclaimer: This is not essentially a productivity tip. But rather, something I experienced while coding.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  The Context
&lt;/h1&gt;

&lt;p&gt;I was casually sharing some programming differences to my friends. The programming language was C, the topic was:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Difference between &lt;code&gt;if-else if&lt;/code&gt; and &lt;code&gt;if if&lt;/code&gt; conditions&lt;/em&gt;.&lt;br&gt;
And the code was like:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;

    &lt;span class="c1"&gt;// if-if statement&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 2+2 is 4."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 5+3 is 8."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// if-else if statement&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 9+8 is 17."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 9+3 is 12."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first, I wanted to demonstrate the if-if statement. Therefore I &lt;strong&gt;commented&lt;/strong&gt; the &lt;code&gt;if-else if&lt;/code&gt; statement out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;

    &lt;span class="c1"&gt;// if-if statement&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 2+2 is 4."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 5+3 is 8."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// if-else if statement&lt;/span&gt;

    &lt;span class="cm"&gt;/*
    if(9+8 == 17){
       printf("\nI execute because 9+8 is 17.");
    }else if(9+3 = 12){
       printf("\nI execute because 9+3 is 12.")
    }
    */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the first demonstration, I had to demonstrate the &lt;code&gt;if-else if&lt;/code&gt; statement. So, in order to make it executable, obviously I had to &lt;strong&gt;uncomment&lt;/strong&gt; it by removing those &lt;code&gt;/* */&lt;/code&gt; symbols (aka multiple line comment).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;But, I being Rahul Dahal, had a crazy thought like,&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What if I put &lt;code&gt;//&lt;/code&gt; (aka single line comment) before the &lt;code&gt;/*&lt;/code&gt; &amp;amp; &lt;code&gt;*/&lt;/code&gt; (multiple line comment start and end), to comment them out and make the text inside it executable ?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically, I wanted to check if we can &lt;em&gt;comment out a comment&lt;/em&gt;. So that &lt;em&gt;comment&lt;/em&gt; will no longer be a &lt;em&gt;comment&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  I did that.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;

    &lt;span class="c1"&gt;// if-if statement&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 2+2 is 4."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 5+3 is 8."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// if-else if statement&lt;/span&gt;

    &lt;span class="c1"&gt;// /*&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 9+8 is 17."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
       &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I execute because 9+3 is 12."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  And guess what, it worked!
&lt;/h2&gt;

&lt;p&gt;That &lt;em&gt;trick&lt;/em&gt; worked. As I expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  But Why? Why did it work ?
&lt;/h2&gt;

&lt;p&gt;Answer,&lt;br&gt;
Actually what happens is, whatever we type after the comment starter (both &lt;code&gt;//&lt;/code&gt; &amp;amp; &lt;code&gt;/*&lt;/code&gt;), no matter what, the compiler &lt;em&gt;understands&lt;/em&gt; it as a comment text.&lt;/p&gt;

&lt;p&gt;That is why the &lt;code&gt;/*&lt;/code&gt; itself was treated as a &lt;em&gt;normal&lt;/em&gt; text.&lt;/p&gt;

&lt;p&gt;And since, &lt;code&gt;/*&lt;/code&gt; is treated as a normal text, the code after it will no longer be commented out. Hence, making it &lt;strong&gt;executable&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
