<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>block Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/block/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/block/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Mon, 16 Jan 2023 13:52:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Classes in Kotlin &#8211; Part 2</title>
		<link>https://creatronix.de/classes-in-kotlin-part-2/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Tue, 19 Oct 2021 06:40:39 +0000</pubDate>
				<category><![CDATA[Kotlin & Java]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[ctor]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[kotlin]]></category>
		<guid isPermaLink="false">https://creatronix.de/?p=3802</guid>

					<description><![CDATA[<p>In Part 1 we dealt with the simplest form of initialization with the primary constructor: class Planet( val diameter: Int, val distanceToSun: Double, val mass: Double ) But wait: there is more: Init block The primary constructor cannot contain any code so init block for the rescue: class Planet( val diameter: Int, val distanceToSun: Double,&#8230;</p>
<p>The post <a href="https://creatronix.de/classes-in-kotlin-part-2/">Classes in Kotlin &#8211; Part 2</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In<a href="https://creatronix.de/classes-in-kotlin/"> Part 1</a> we dealt with the simplest form of initialization with the primary constructor:</p>
<pre>class Planet(
    val diameter: Int,
    val distanceToSun: Double,
    val mass: Double
)</pre>
<p>But wait: there is more:</p>
<h2>Init block</h2>
<p>The primary constructor cannot contain any code so init block for the rescue:</p>
<pre>class Planet(
    val diameter: Int,
    val distanceToSun: Double,
    val mass: Double
) {
    val circumference = PI * diameter
    init {
        println(circumference)
    }
}</pre>
<p>Notes:</p>
<ul>
<li>You can have more than one init block</li>
<li>they run in order of their declaration</li>
</ul>
<p>The post <a href="https://creatronix.de/classes-in-kotlin-part-2/">Classes in Kotlin &#8211; Part 2</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
