<?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>string interpolation Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/string-interpolation/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/string-interpolation/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Thu, 23 Oct 2025 13:10:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.1</generator>
	<item>
		<title>Learning Kotlin &#8211; Part 1 &#8211; strings and print</title>
		<link>https://creatronix.de/learning-kotlin-part-1/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Fri, 17 May 2019 08:45:31 +0000</pubDate>
				<category><![CDATA[Kotlin & Java]]></category>
		<category><![CDATA[kotlin]]></category>
		<category><![CDATA[string interpolation]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=2654</guid>

					<description><![CDATA[<p>Motivation I wanted to try writing an Android app. In spite of using plain old Java I wanted to give the new kid on the block Kotlin (from the Jetbrains folks) a try. First observations Coming from a Python background it&#8217;s good to see that Kotlin doesn&#8217;t use semi-colons! But the curly braces from Java&#8230;</p>
<p>The post <a href="https://creatronix.de/learning-kotlin-part-1/">Learning Kotlin &#8211; Part 1 &#8211; strings and print</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Motivation</h2>
<p><img decoding="async" class="alignnone size-full wp-image-2664" src="https://creatronix.de/wp-content/uploads/2019/05/Kotlin-logo.png" alt="" width="152" height="151" srcset="https://creatronix.de/wp-content/uploads/2019/05/Kotlin-logo.png 152w, https://creatronix.de/wp-content/uploads/2019/05/Kotlin-logo-150x150.png 150w, https://creatronix.de/wp-content/uploads/2019/05/Kotlin-logo-100x100.png 100w" sizes="(max-width: 152px) 100vw, 152px" /></p>
<p>I wanted to try writing an Android app. In spite of using plain old Java I wanted to give the new kid on the block <a href="https://kotlinlang.org/">Kotlin</a> (from the Jetbrains folks) a try.</p>
<h2>First observations</h2>
<p>Coming from a Python background it&#8217;s good to see that Kotlin doesn&#8217;t use semi-colons! But the curly braces from Java make code blocks are still there, hmpf&#8230;</p>
<h2>Variables</h2>
<p>Kotlin has two ways of declaring &#8220;variables&#8221;:</p>
<ul>
<li>va<strong>r</strong>: think variable: this is a mutable</li>
<li>va<strong>l</strong>: think values: this is read-only like const</li>
</ul>
<h2>Data Types and Type Inference</h2>
<p>A nice thing about Kotlin is type inference. When it is clear which data type is meant you can leave out the data type from the declaration</p>
<h3>Strings</h3>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-java" data-lang="Kotlin"><code>val firstName = "Tony" 
val lastName = "Stark"</code></pre>
</div>
<h4>Concatenation</h4>
<p>You can concatenate strings with the plus operator as you can do it in Python</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-java" data-lang="Kotlin"><code>val fullName: String = firstName + " " + lastName</code></pre>
</div>
<h4>Print and String interpolation</h4>
<p>Kotlin has a built-in println function so you can stop typing System.out.println()</p>
<p>Less visual noise!</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-java" data-lang="Kotlin"><code>println(fullName)</code></pre>
</div>
<p>A neat little feature is the string interpolation syntax. If You want to concatenate strings for logging output, you can write $stringName Locks similar to the Python <a href="https://creatronix.de/f-strings-in-python/">f-Strings</a></p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-java" data-lang="Kotlin"><code>println("Name: $fullName")</code></pre>
</div>
<p>But there is more to it:<br />
You can for example call functions inside strings as well:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-java" data-lang="Kotlin"><code>println("String length: ${fullName.length}")</code></pre>
</div>
<p>or access indices</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-java" data-lang="Kotlin"><code>println("2nd Index: ${fullName[2]}")</code></pre>
</div>
<p><a href="https://creatronix.de/learning-kotlin-part-2/">Ready for Part 2?</a></p>
<p>The post <a href="https://creatronix.de/learning-kotlin-part-1/">Learning Kotlin &#8211; Part 1 &#8211; strings and print</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
