<?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"><channel><title><![CDATA[nehal's tech diary]]></title><description><![CDATA[Software Engineer | Technical Blogger | Exploring and Refactoring!]]></description><link>https://nehal.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 16:05:12 GMT</lastBuildDate><atom:link href="https://nehal.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Master RxJS]]></title><description><![CDATA[ToDo]]></description><link>https://nehal.hashnode.dev/master-rxjs</link><guid isPermaLink="true">https://nehal.hashnode.dev/master-rxjs</guid><category><![CDATA[RxJS]]></category><dc:creator><![CDATA[Md Nehaluddin Haider]]></dc:creator><pubDate>Mon, 02 Jan 2023 06:45:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/a62f81f6c17704feaaac23034296ce63.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>ToDo</p>
]]></content:encoded></item><item><title><![CDATA[DSA- Important Matrix Questions]]></title><description><![CDATA[Set 1

Matrix in Snake Pattern.
Transpose of a matrix.
Search in row-wise and coumn-wise sorted matrix.
Spiral Transversal of a matrix.]]></description><link>https://nehal.hashnode.dev/dsa-important-matrix-questions</link><guid isPermaLink="true">https://nehal.hashnode.dev/dsa-important-matrix-questions</guid><dc:creator><![CDATA[Md Nehaluddin Haider]]></dc:creator><pubDate>Sun, 03 Jul 2022 07:31:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/taPsJHnNJ_8/upload/v1656833260702/O79V0KjND.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-set-1">Set 1</h2>
<ol>
<li>Matrix in Snake Pattern.</li>
<li>Transpose of a matrix.</li>
<li>Search in row-wise and coumn-wise sorted matrix.</li>
<li>Spiral Transversal of a matrix.</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[kotlin]]></title><description><![CDATA[fun main(args: Array<String>) {
    println("Hello, World!")
}]]></description><link>https://nehal.hashnode.dev/kotlin</link><guid isPermaLink="true">https://nehal.hashnode.dev/kotlin</guid><dc:creator><![CDATA[Md Nehaluddin Haider]]></dc:creator><pubDate>Wed, 25 Aug 2021 10:37:17 GMT</pubDate><content:encoded><![CDATA[<pre><code><span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">main</span><span class="hljs-params">(args: <span class="hljs-type">Array</span>&lt;<span class="hljs-type">String</span>&gt;)</span></span> {
    println(<span class="hljs-string">"Hello, World!"</span>)
}
</code></pre>]]></content:encoded></item><item><title><![CDATA[Kotlin- Properties, Getters, Setters]]></title><description><![CDATA[Introduction
Kotlin properties are variables that are declared inside the class but outside the method.
It can be declared either as mutable using the var' keyword or read-only using the val keyword.
Full syntax for declaring a property:
var <propert...]]></description><link>https://nehal.hashnode.dev/kotlin-properties-getters-setters</link><guid isPermaLink="true">https://nehal.hashnode.dev/kotlin-properties-getters-setters</guid><category><![CDATA[Kotlin]]></category><category><![CDATA[kotlin beginner]]></category><dc:creator><![CDATA[Md Nehaluddin Haider]]></dc:creator><pubDate>Wed, 11 Nov 2020 12:01:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1606309879053/9EXm8B9ax.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="introduction">Introduction</h3>
<p>Kotlin properties are variables that are declared inside the <code>class</code> but outside the <code>method</code>.</p>
<p>It can be declared either as mutable using the <code>var'</code> keyword or read-only using the <code>val</code> keyword.</p>
<p>Full syntax for declaring a property:</p>
<pre><code>var <span class="hljs-tag">&lt;<span class="hljs-name">propertyName</span>&gt;</span>[: <span class="hljs-tag">&lt;<span class="hljs-name">PropertyType</span>&gt;</span>] [= <span class="hljs-tag">&lt;<span class="hljs-name">property_initializer</span>&gt;</span>]
    [<span class="hljs-tag">&lt;<span class="hljs-name">getter</span>&gt;</span>]
    [<span class="hljs-tag">&lt;<span class="hljs-name">setter</span>&gt;</span>]
</code></pre><p>The initializer, getter and setter are optional. Property type is optional if it can be inferred from the initializer.</p>
<h4 id="examples-of-properties">Examples of properties</h4>
<pre><code>var <span class="hljs-type">name</span>: String = "Mike" 
var <span class="hljs-type">name</span> = "Mike" // <span class="hljs-keyword">type</span> <span class="hljs-keyword">is</span> inferred <span class="hljs-keyword">as</span> String, hence omitted
var <span class="hljs-type">name</span> = "John" // var can be re-assigned

val <span class="hljs-type">name</span> = "Mike"
val <span class="hljs-type">name</span> = "John" // It cannot be re-assigned
</code></pre><blockquote>
<p>By default, properties in Kotlin are <code>public</code> and <code>final</code>. For <code>private</code> and <code>protected</code> you need to add it explicitly.</p>
</blockquote>
<h3 id="getters-and-setters-accessors">Getters and Setters (Accessors)</h3>
<p>As the name suggests, getters are used for getting value of the property. Similarly, setters are used for setting value of the property.</p>
<p>In Kotlin, getters and setters are optional and are auto-generated if you do not create them.</p>
<h4 id="auto-generated-accessors">Auto-generated Accessors</h4>
<pre><code><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Country</span> </span>{
<span class="hljs-keyword">var</span> currency: <span class="hljs-keyword">String</span> = <span class="hljs-string">"dollar"</span>
}
</code></pre><p>The above code is equivalent to </p>
<pre><code><span class="hljs-keyword">class</span> <span class="hljs-title">Country</span> {
    <span class="hljs-keyword">var</span> currency: String = <span class="hljs-string">"dollar"</span>

    <span class="hljs-keyword">get</span>() = field       <span class="hljs-comment">// getter</span>

    <span class="hljs-keyword">set</span>(<span class="hljs-keyword">value</span>) {        <span class="hljs-comment">// setter</span>
        field = <span class="hljs-keyword">value</span>
    }
}
</code></pre><p>Since, we do not modify accessors here, so we can omit it and use it like </p>
<pre><code><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Country</span> </span>{
<span class="hljs-keyword">var</span> currency: String = <span class="hljs-string">"dollar"</span>
}

<span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
<span class="hljs-keyword">val</span> c= Country()
c.currency = <span class="hljs-string">"rupee"</span>  <span class="hljs-comment">// access setter</span>
println(<span class="hljs-string">"<span class="hljs-subst">${c.currency}</span>"</span>) <span class="hljs-comment">// access getter</span>
}
</code></pre><h4 id="field-and-value-identifiers">Field and Value Identifiers</h4>
<ol>
<li>Value:</li>
</ol>
<p>Conventionally, we choose the name of the setter parameter is value, but we can choose a different name if we want. The value parameter contains the value that a property is assigned to.
In above program, we have initialized the property name as c.currency = “dollar”, the value parameter contains the assigned value “dollar”.</p>
<ol>
<li>Backing Field (field):</li>
</ol>
<p>It helps in storing the property value in memory possible. When we initialize a property with a value, the initialized value is written to the backing field of that property.
In above program, the value is assigned to field and then field is assigned to get().</p>
<h4 id="custom-accessors">Custom Accessors</h4>
<p>We can override auto-generated accessors</p>
<pre><code><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Country</span> </span>{
    <span class="hljs-keyword">var</span> currency: String = <span class="hljs-string">"dollar"</span>

    <span class="hljs-keyword">get</span>() {  <span class="hljs-comment">// custom getter </span>
           <span class="hljs-keyword">return</span> field.toLowerCase() 
        } 

    <span class="hljs-keyword">set</span>(value) {  <span class="hljs-comment">// custom setter</span>
        field = <span class="hljs-keyword">if</span>(value = <span class="hljs-string">"dollar"</span> ) value <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> IllegalArgumentException(<span class="hljs-string">"Currency must be dollar"</span>) 
    }
}
</code></pre>]]></content:encoded></item></channel></rss>