All Discussions Tagged 'Kotlin' - Codetown2024-03-28T13:44:49Zhttps://codetown.com/group/kotlin/forum/topic/listForTag?tag=Kotlin&feed=yes&xn_auth=noCoroutine-First Android Architecture w/ Rick Busarowtag:codetown.com,2019-07-20:2197786:Topic:1053092019-07-20T16:14:42.027ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<p style="text-align: center;"><strong>Chicago Kotlin User Group x Android Listeners</strong></p>
<p style="text-align: center;">Hosted at GrubHub, July 17</p>
<p style="text-align: left;"><span>Coroutines are the new hot stuff, and right now they’re being added to lots of libraries. But what if you don’t want to use an alpha01 in production code? What can coroutines do on their own, right now? In this talk, we’ll discuss the power behind structured concurrency and how we can use it to make our…</span></p>
<p style="text-align: center;"><strong>Chicago Kotlin User Group x Android Listeners</strong></p>
<p style="text-align: center;">Hosted at GrubHub, July 17</p>
<p style="text-align: left;"><span>Coroutines are the new hot stuff, and right now they’re being added to lots of libraries. But what if you don’t want to use an alpha01 in production code? What can coroutines do on their own, right now? In this talk, we’ll discuss the power behind structured concurrency and how we can use it to make our entire stack lifecycle-aware. We’ll look at examples of how to turn any callback or long-running code into a coroutine, and we’ll go over when and how to use Channels to handle hot streams of data without leaking. Finally, and most importantly, we’ll see how we can use these tools to inform our application architecture, so that we can quickly write maintainable and testable features. Thanks to GrubHub for hosting!</span></p>
<p style="text-align: left;"></p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/WIL6xw8cRwA?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p> Coroutine-First Android Architecture w/ Rick Busarowtag:codetown.com,2019-07-20:2197786:Topic:1054842019-07-20T16:14:41.340ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<p style="text-align: center;"><strong>Chicago Kotlin User Group x Android Listeners</strong></p>
<p style="text-align: center;">Hosted at GrubHub, July 17</p>
<p style="text-align: left;"><span>Coroutines are the new hot stuff, and right now they’re being added to lots of libraries. But what if you don’t want to use an alpha01 in production code? What can coroutines do on their own, right now? In this talk, we’ll discuss the power behind structured concurrency and how we can use it to make our…</span></p>
<p style="text-align: center;"><strong>Chicago Kotlin User Group x Android Listeners</strong></p>
<p style="text-align: center;">Hosted at GrubHub, July 17</p>
<p style="text-align: left;"><span>Coroutines are the new hot stuff, and right now they’re being added to lots of libraries. But what if you don’t want to use an alpha01 in production code? What can coroutines do on their own, right now? In this talk, we’ll discuss the power behind structured concurrency and how we can use it to make our entire stack lifecycle-aware. We’ll look at examples of how to turn any callback or long-running code into a coroutine, and we’ll go over when and how to use Channels to handle hot streams of data without leaking. Finally, and most importantly, we’ll see how we can use these tools to inform our application architecture, so that we can quickly write maintainable and testable features. Thanks to GrubHub for hosting!</span></p>
<p style="text-align: left;"></p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/WIL6xw8cRwA?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p> Kotlin Thursdays Presents: Tea Time - Bad Bosses with Brittney Braxtontag:codetown.com,2018-12-06:2197786:Topic:617362018-12-06T20:15:37.884ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<p><span>This week, Ben Rodriguez and Brittney Baxton discusses ways leaders and organizations help shape (or hinder) engineer development.</span></p>
<p></p>
<p></p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/xJodwuz03gg?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p>
<p><span>This week, Ben Rodriguez and Brittney Baxton discusses ways leaders and organizations help shape (or hinder) engineer development.</span></p>
<p></p>
<p></p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/xJodwuz03gg?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p> Kotlin Thursdays - Image Processing in Kotlin Part 3 with Amanda Hinchman-Domingueztag:codetown.com,2018-11-16:2197786:Topic:615182018-11-16T17:25:02.547ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<div class="flexible_container" style="align-items: stretch; justify-content: space-between; display: flex; box-sizing: border-box; background: white; color: black;"><div class="official_links" style="padding: 10px; text-align: center;"><h1 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Kotlin Thursdays: Image Processing in Kotlin Part 3</h1>
<p style="text-align: left;"><strong>Part 1:…</strong></p>
</div>
</div>
<div class="flexible_container" style="align-items: stretch; justify-content: space-between; display: flex; box-sizing: border-box; background: white; color: black;"><div class="official_links" style="padding: 10px; text-align: center;"><h1 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Kotlin Thursdays: Image Processing in Kotlin Part 3</h1>
<p style="text-align: left;"><strong>Part 1: <a href="https://codetown.com/group/kotlin/forum/topics/kotlin-thursdays-image-processing-in-kotlin-with-amanda-hinchmanhttps://codetown.com/group/kotlin/forum/topics/kotlin-thursdays-image-processing-in-kotlin-with-amanda-hinchman" target="_blank" rel="noopener">https://codetown.com/group/kotlin/forum/topics/kotlin-thursdays-image-processing-in-kotlin-with-amanda-hinchman</a></strong></p>
<p style="text-align: left;"><strong>Part 2: <a href="https://codetown.com/group/kotlin/forum/topics/kotlin-thursdays-image-processing-in-kotlin-part-3-with-amanda" target="_blank" rel="noopener">https://codetown.com/group/kotlin/forum/topics/kotlin-thursdays-image-processing-in-kotlin-part-3-with-amanda</a></strong></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">Welcome to Kotlin Thursdays! <a href="https://codetown.com/group/kotlin/forum/topics/kotlin-thursdays-image-processing-in-kotlin-part-2-with-amanda" target="_blank" rel="noopener">Last week,</a><span style="font-weight: 400;"> we figured out how to write primitive filters and apply them to our images with the</span> <b>or</b> <span style="font-weight: 400;">function. This week, we look at refactoring with <em>higher-order functions.</em></span></p>
<p style="color: black;"></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/MsY9HmETvZY?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
<p style="color: black;"></p>
<h2 class="subdescription" style="font-weight: 500; color: #aeb1b7; text-align: left;">Resources</h2>
<p style="text-align: left;">Think of these resources as supplemental if you happen to be more curious. We always encourage looking into documentation for things you use!</p>
<ul style="text-align: left;">
<li><strong>Project Github Repository: <a href="https://github.com/Kotlin-Thursdays/Image-Processing-in-Kotlin" target="_blank" rel="noopener">https://github.com/Kotlin-Thursdays/Image-Processing-in-Kotlin</a></strong></li>
<li><strong>Installing Java with Oracle: </strong> <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html" target="_blank" rel="noopener">https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html</a></li>
<li><strong>Kotlin</strong>: <a href="https://kotlinlang.org/docs/reference/" target="_blank" rel="noopener">https://kotlinlang.org/docs/reference/</a></li>
<li><strong>TornadoFX: <a href="https://edvin.gitbooks.io/tornadofx-guide/content/"><span style="font-weight: 400;">https://edvin.gitbooks.io/tornadofx-guide/content/</span></a></strong></li>
</ul>
<div class="topic_container" style="text-align: left;"></div>
<p style="text-align: left;"></p>
<h2 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Higher Order Functions</h2>
<p style="text-align: left;"><span>We could continue to write individual functions that feeds 2 images and a particular function, but in Kotlin, we have the ability to use a single function that accepts 2 images and a function with the help of <i>higher order functions. </i> Below, you can see how similar our <strong>orFilter</strong> function and <strong>makeDuller</strong> function is.</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><a href="https://storage.ning.com/topology/rest/1.0/file/get/135396997?profile=original" target="_blank" rel="noopener"><img src="https://storage.ning.com/topology/rest/1.0/file/get/135396997?profile=original&width=450" width="450" class="align-center" style="padding: 10px;"/></a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">In programming, programs may take data as parameters and pass those parameters into the function to return a different output or alter the behavior of a program. Kotlin is a functional language, and one characteristic of a functional language is that functions are also able to treat functions as data. You can pass a function as a parameter, which is really powerful!</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;"><a href="https://storage.ning.com/topology/rest/1.0/file/get/135397812?profile=original" target="_blank" rel="noopener"><img src="https://storage.ning.com/topology/rest/1.0/file/get/135397812?profile=original&width=450" width="450" class="align-center" style="padding: 10px;"/></a></span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">A <strong>higher-order function</strong> is a function that may take functions as parameters. <span>You can pass a function with</span> <span>double-colon (</span><span>::</span><span>)</span><span>. </span><span>Double-colon (</span><span>::</span><span>) is used to get function (callable) reference in Kotlin</span><span>.</span></span></p>
<p style="text-align: left;"><span style="font-weight: 400;"><a href="https://storage.ning.com/topology/rest/1.0/file/get/135397892?profile=original" target="_blank" rel="noopener"><img src="https://storage.ning.com/topology/rest/1.0/file/get/135397892?profile=original&width=450" width="450" class="align-center" style="padding: 10px;"/></a></span></p>
<p style="text-align: left;"><span style="font-weight: 400;">Ruby facilitates higher order functions with</span> <b>yield, which involves passing a block to a method.</b></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">Like Ruby, Kotlin treats functions as</span> <b>first-class citizens</b><span style="font-weight: 400;">, which is a pillar of functional programming.</span> <b><i>In Kotlin, the equivalent of block code is known as lambda functions, indicated by the pattern:</i></b><a href="https://storage.ning.com/topology/rest/1.0/file/get/135397654?profile=original" target="_blank" rel="noopener"><img src="https://storage.ning.com/topology/rest/1.0/file/get/135397654?profile=original&width=450" width="450" class="align-center" style="padding: 10px;"/></a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">Instead of passing the object as an argument, you invoke the lambda variable as it if were an extension function. Haskell also has higher order functions which can designate the kinds of parameters a function may take within a function.</span></p>
<h2 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Implementing applyFilter</h2>
<p style="text-align: left;"><span>In this case, we are going to work with a general function, as opposed to an extension function that is invoked with a qualifer.</span></p>
<p style="text-align: left;"><span>The function we write will take a filter function and 2 pixelReaders. Our function parameter, in particular, will only accept functions that take 2 Color parameters and returns a Color. </span></p>
<p style="text-align: left;"><br/> <span>So here, the</span> <b>input function that accepts the 2 parameters is the</b> <i><span>receiver type</span></i><span>, the output</span> <b>Color</b> <i><span>receiver object.</span></i></p>
<p style="color: black;"></p>
<div class="code-container" style="border-radius: 4px; border: 1px solid #cccccc; box-sizing: border-box; padding: 10px; text-align: left;"><p style="color: black;"><span style="color: #d73a49;">fun</span> <span style="color: #6f42c1;">applyFilter </span>(filter<span style="color: #d73a49;">:</span> (Color, Color) --> Color, a<span>:</span> PixelReader, b<span style="color: #d73a49;">:</span> PixelReader): PixelWriter {</p>
<p style="padding-left: 2em; color: #d73a49;"><span style="color: #d73a49;">for <span style="color: black;">(x</span> in <span style="color: #005cc5;">0</span> </span>until<font color="#D73A49"> width</font><span style="color: black;">) {</span></p>
<p style="padding-left: 2em; color: #d73a49;"> for <span style="color: black;">(y</span> in <span style="color: #005cc5;">0</span> until height<span style="color: black;">) {</span></p>
<p style="padding-left: 4em;"><span style="color: black;">resultWriter.setColor(x, y, filter(a.getColor(x, y), b.getColor(x, y))</span></p>
<p style="padding-left: 2em;"> } </p>
<p style="color: black;"> }</p>
<p style="padding-left: 2em; color: #d73a49;">return <span style="color: black;">resultWriter</span></p>
<p style="color: black;">}</p>
</div>
<h2 class="subdescription" style="font-weight: 500; color: #aeb1b7; text-align: left;">Conclusion</h2>
<p style="text-align: left;">I hope you all had fun learning a little bit about image processing! Keep exploring and creating new image filters and maybe even as a challenge, think about how you might implement an RGB system to create image filters for colors. Until next time :)</p>
<p style="text-align: left;"></p>
</div>
</div> Kotlin Thursdays Presents: Tea Time - The Toxic Engineering Environment with JP Fairfieldtag:codetown.com,2018-11-09:2197786:Topic:614182018-11-09T01:50:56.200ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<p style="text-align: left;"></p>
<p style="text-align: left;"><span>This Kotlin Thursday, Amanda and JP Fairfield talk about working overtime in tech.</span></p>
<p style="text-align: center;"></p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/zH-JkwlV1BI?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span>This Kotlin Thursday, Amanda and JP Fairfield talk about working overtime in tech.</span></p>
<p style="text-align: center;"></p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/zH-JkwlV1BI?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p> Kotlin Thursdays - Collection Mechanics with Matt Mooretag:codetown.com,2018-10-25:2197786:Topic:613892018-10-25T06:49:26.647ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<div class="flexible_container" style="align-items: stretch; justify-content: space-between; display: flex; box-sizing: border-box; background: white; color: black;"><div class="official_links" style="padding: 10px; text-align: center;"><h1 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Kotlin Thursdays: Collection Mechanics</h1>
<p style="text-align: left;">Welcome to the first Kotlin Thursday of the season! We're glad to have you here.…</p>
</div>
</div>
<div class="flexible_container" style="align-items: stretch; justify-content: space-between; display: flex; box-sizing: border-box; background: white; color: black;"><div class="official_links" style="padding: 10px; text-align: center;"><h1 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Kotlin Thursdays: Collection Mechanics</h1>
<p style="text-align: left;">Welcome to the first Kotlin Thursday of the season! We're glad to have you here.</p>
<p style="text-align: left;">This week, we're going to look into getting started with Kotlin and reviewing some fundamental concepts in programming. Let's get started!</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/YDlxbct9ez4?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
<p style="text-align: left;"></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/ETgkKV5B2CU?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
<p></p>
<h2 class="subdescription" style="font-weight: 500; color: #aeb1b7; text-align: left;">Resources</h2>
<p style="text-align: left;">Think of these resources as supplemental if you happen to be more curious. We always encourage looking into documentation for things you use!</p>
<ul style="text-align: left;">
<li><strong>Installing Java with Oracle: </strong> <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html" target="_blank" rel="noopener">https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html</a></li>
<li><strong>Kotlin</strong>: <a href="https://kotlinlang.org/docs/reference/" target="_blank" rel="noopener">https://kotlinlang.org/docs/reference/</a></li>
<li><strong>Kotlin Basic Types: </strong> <a href="https://kotlinlang.org/docs/reference/basic-types.html" target="_blank" rel="noopener">https://kotlinlang.org/docs/reference/basic-types.html</a><strong> </strong></li>
<li><strong>Kotlin Collections:</strong> <a href="https://kotlinlang.org/docs/reference/collections.html" target="_blank" rel="noopener">https://kotlinlang.org/docs/reference/collections.html</a></li>
<li><strong>Using a Terminal:</strong> <a href="https://macpaw.com/how-to/use-terminal-on-mac" target="_blank" rel="noopener">https://macpaw.com/how-to/use-terminal-on-mac</a></li>
<li><strong>Using a Windows Command Line: </strong><a href="https://www.computerhope.com/issues/chusedos.htm" target="_blank" rel="noopener">https://www.computerhope.com/issues/chusedos.htm</a></li>
</ul>
<div class="topic_container" style="display: inline-block; flex-basis: 100%; text-align: left;"><h2 class="subdescription" style="font-weight: 500; color: #aeb1b7;">Topics covered:</h2>
<ul>
<li id="5ad6" class="graf graf--li graf-after--h3"><strong>Installing Java</strong></li>
<li id="c53b" class="graf graf--li graf-after--li"><strong>Installing Kotlin</strong></li>
<li class="graf graf--li graf-after--li"><strong>What's a Computer?</strong></li>
<li class="graf graf--li graf-after--li"><strong>Arrays</strong></li>
<li class="graf graf--li graf-after--li"><strong>Lists</strong></li>
</ul>
<p></p>
</div>
<p style="text-align: left;">Before we can begin working with Kotlin, you’ll need to set up Kotlin on your computer.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">However, if you’d like to just try Kotlin out without having to install anything on your computer, you can try Kotlin in the browser: <a href="https://play.kotlinlang.org" target="_blank" rel="noopener">https://play.kotlinlang.org</a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">Here’s a hello world example: <a href="https://try.kotlinlang.org/#/Examples/Hello,%20world!/Simplest%20version/Simplest%20version.kt" target="_blank" rel="noopener">https://try.kotlinlang.org/#/Examples/Hello,%20world!/Simplest%20version/Simplest%20version.kt</a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">If you'd like to install a repl on your own computer:</p>
<ul style="text-align: left;">
<li><strong>Mac</strong> - if you're on macOS, the easiest way to do this is using Homebrew. <span style="font-weight: 400;">To install homebrew, follow the directions on the</span> <a href="http://brew.sh"><span style="font-weight: 400;">Homebrew website</span></a><span style="font-weight: 400;">.</span></li>
<li><span style="font-weight: 400;"><strong>Windows -</strong> Follow the directions here:</span> <a href="http://otfried.org/courses/cs109/project-install.html"><span style="font-weight: 400;">http://otfried.org/courses/cs109/project-install.html</span></a></li>
</ul>
<h2 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Java Setup on Mac</h2>
<p style="text-align: left;"><span style="font-weight: 400;">Kotlin requires Java to be installed. To do this on a Mac:</span></p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">brew cask install java8</span></code><br/>
<p style="text-align: left;"></p>
<h2 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Kotlin Setup on Mac</h2>
<p style="text-align: left;"><span style="font-weight: 400;">Next, you will need to install the Kotlin compiler. Open your terminal and run the following command:</span></p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">brew install kotlin</span></code><br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">Let’s test if our Kotlin compiler works, by creating a startup program.. Create a text file named “Hello.kt”. Open it in your favorite text editor and add the following code:</p>
<p style="text-align: left;"></p>
<div class="code-container" style="border-radius: 4px; border: 1px solid #cccccc; box-sizing: border-box; padding: 10px; text-align: left;"><p style="color: #d73a49;">package <span style="color: #6f42c1;">Hello</span></p>
<p><span style="color: #d73a49;">fun</span> <span style="color: #6f42c1;">main</span><span style="color: black;">(args<span style="color: #d73a49;">: Array</span><<span style="color: #d73a49;">String</span>>) {</span></p>
<p></p>
<p style="padding-left: 2em;">println("Hello World!")</p>
<p>}</p>
</div>
<br/>
<p style="text-align: left;">Save the text file. Now on the command line, run this command to compile it into an executable file:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">kotlinc Hello.kt -include-runtime -d hello.jar</span></code><br/>
<p style="text-align: left;"></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">This will compile the “Hello.kt” file into a file called “hello.jar”. To execute that file, run this command:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">java -jar hello.jar</span></code><br/>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">Hello World!</span></code><br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">Congratulations! You’ve just successfully written your first Kotlin program and compiled it! Now that we know that Kotlin is working on our machine, let’s get started on writing some more code.</p>
<p style="text-align: left;"></p>
<h2 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">What's a Computer?</h2>
<p style="text-align: left;">Before we get started working with Kotlin, it is helpful to learn a few fundamental concepts about how a computer works, especially with some basic data structures.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">A <strong>computer</strong> is basically a <em>machine that can store things in memory and rearrange its memory</em>. It does this with its processor.</p>
<p style="text-align: left;">So, you can think of a computer as really just a machine (processor) that can put cute aliens into boxes pulls them out again (memory). You can only put one alien at a time though into each box.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><a href="http://storage.ning.com/topology/rest/1.0/file/get/1799505550?profile=original" target="_self"><img width="450" src="http://storage.ning.com/topology/rest/1.0/file/get/1799505550?profile=RESIZE_480x480" width="450" style="padding: 10px;"/></a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">In the first box, I’m going to put a blue alien. In the second I’ll put a green one. The third will hold a red one.</p>
<br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">Now, my processor is a machine that puts these aliens into the boxes and can pull them out again. It can also do things like add the numbers together.</p>
<p style="text-align: left;"></p>
<h2 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">From Aliens to Kotlin</h2>
<p style="text-align: left;">So how do we store something in Kotlin, like the number 1? Let’s create an alien that has the number 1. We can do this with the following Kotlin code:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">var alien1 = 1</span></code><br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">There we have it! We’ve just given the number 1 to our first alien!</p>
<p style="text-align: left;"></p>
<h2 class="title" style="font-weight: 500; color: #f0610b; text-align: left;">Grouping Aliens Together</h2>
<h3 class="subdescription" style="font-weight: 500; color: #aeb1b7; text-align: left;">Arrays</h3>
<p style="text-align: left;"></p>
<p style="text-align: left;">While putting individual items in individual variables is great, there are lots of times we want to store multiple items together. To do this we can create what is called an “array”. An array is a way to create a group of aliens and and then put stuff into them.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">Here’s how we create an array in Kotlin and store the numbers 1, 2 and 3 in them:</p>
<p style="text-align: left;"></p>
<p style="text-align: left;"> <code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;"><strong>var</strong> alien1 = arrayOf(1, 2, 3)</span></code></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">Let’s look at what’s going on here. We’re creating a group of aliens called “aliens”. We’re also storing the numbers <strong>1</strong>, <strong>2</strong> and <strong>3</strong> in them. You may notice that we’re using arrayOf here. That just tells Kotlin that we want to create an <code class="markup--code markup--li-code" style="background-color: #ded7d9;">array</code>. Going back to our picture, we’re making three aliens and storing the numbers in them:</p>
<p style="text-align: left;"></p>
<a href="http://storage.ning.com/topology/rest/1.0/file/get/1799505672?profile=original" target="_self"><img width="450" src="http://storage.ning.com/topology/rest/1.0/file/get/1799505873?profile=RESIZE_480x480" width="450" class="align-center" style="padding: 10px;"/></a><br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">Now, when we create an array in the computer’s memory, there’s something you should know about what’s going on with the computer.</p>
<p style="text-align: left;">Computers have what is called <strong>linear memory</strong>. <strong>Linear memory </strong>is made up of a lot of aliens that come one right after the other. When we create an array, we need to tell the computer two things:</p>
<ol style="text-align: left;">
<li>the number of aliens</li>
<li>the stuff we want to put into them</li>
</ol>
<p style="text-align: left;"></p>
<p style="text-align: left;">Note that Kotlin can automatically count how many aliens are needed by counting the number of things we tell it to create. Then the computer finds the necessary number of aliens and sets them aside. It also stores the values we give it into those aliens.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">Whenever we want to get a specific value out of a alien, we can do the following:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">aliens[0]</span></code><br/>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">1</span></code> <-- output<br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">What is this aliens[0] business? Well, that’s how we identify which alien in the array we want to change. First, the aliens array is the group of aliens we’re telling Kotlin we want to change. Next, the [0] part tells Kotlin which alien in the group we want to change. In this case, we’re changing the first alien. But why do we use 0? Well, a long time ago programmers decided they wanted to start counting from zero instead of one. So now, lots of programming languages do it this way. Silly, right? If we wanted to get the number stored in the second alien, we would use the number 1:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">aliens[1]</span></code><br/>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">2</span></code> <-- output<br/>
<p style="text-align: left;"></p>
<p style="text-align: left;"><a href="http://storage.ning.com/topology/rest/1.0/file/get/1799506013?profile=original" target="_self"><img width="450" src="http://storage.ning.com/topology/rest/1.0/file/get/1799506013?profile=RESIZE_480x480" width="450" class="align-center" style="padding: 10px;"/></a></p>
<p style="text-align: left;"><span style="font-weight: 400;">So when you’re trying to figure out which alien you want to change, and you find yourself confused, just remember: whichever alien you want to change, subtract the number 1 from it and you’ll get the right one.</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">But what if we want to add another alien? With an array, we cannot do this. The reason has to do with how the computer stores information. When we told the computer to create an array of three aliens, the computer set those aside. However, the rest of the memory is up for grabs - any other group of aliens can be claimed.</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">Let’s say our computer only has 10 aliens available to use.</span></p>
<p style="text-align: left;"><span style="font-weight: 400;"><a href="http://storage.ning.com/topology/rest/1.0/file/get/1799506049?profile=original" target="_self"><img width="350" src="http://storage.ning.com/topology/rest/1.0/file/get/1799506049?profile=RESIZE_480x480" width="350" class="align-center" style="padding: 10px;"/></a></span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">If we set aside the first 2, we only have 8 aliens left.</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;"><a href="http://storage.ning.com/topology/rest/1.0/file/get/1799506182?profile=original" target="_self"><img width="450" src="http://storage.ning.com/topology/rest/1.0/file/get/1799506182?profile=RESIZE_480x480" width="450" class="align-center" style="padding: 10px;"/></a></span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">If we create another array storing 2 more aliens, we end up with something like this:</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;"><a href="http://storage.ning.com/topology/rest/1.0/file/get/1799506335?profile=original" target="_self"><img width="450" src="http://storage.ning.com/topology/rest/1.0/file/get/1799506335?profile=RESIZE_480x480" width="450" class="align-center" style="padding: 10px;"/></a></span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">In order for the computer to keep track of the aliens in the array we have to keep them next to each other.</span></p>
<p style="text-align: left;"><span style="font-weight: 400;">The computer knows where the first alien in the array begins, and it also knows how many it has set aside for the aliens.</span></p>
<p style="text-align: left;"><span style="font-weight: 400;">But it needs to keep them all together, because it needs to know how to get to each one.</span></p>
<p style="text-align: left;"><span style="font-weight: 400;">As long as it keeps them together, it’s fairly easy to find the right aliens that belong to the group, because all it has to do is move to the next one.</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">The processor knows that in order to go from the first alien to the second, it can just move to the next alien with a known position.</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">If it wants the last one, it knows the location of the first alien and it also knows the number of aliens, so it can just count how many aliens there are and then moves directly to the last alien.</span></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"> </p>
<p style="text-align: left;"><a href="https://giphy.com/gifs/3tMs4TT4jy3SLI9ScV">via GIPHY</a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><span style="font-weight: 400;">Because we want to make sure the computer has a way to find the correct alien, we can’t add new aliens to that array because it would interfere with other arrays that might have been created as well. But there’s a solution to this problem! They’re called lists.</span></p>
<h3 class="subdescription" style="font-weight: 500; color: #aeb1b7; text-align: left;">Lists</h3>
<p style="text-align: left;"></p>
<p style="text-align: left;"><strong>A list</strong> is another way to create a group of aliens and then put stuff into them. A list also allows us to group these aliens by a name so that we can easily keep stuff together. Let’s say we want to create a list (or group) of aliens with a single name and then store the numbers 1, 2 and 3 in them:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">var aliens = mutableListOf(1, 2, 3)</span></code><br/>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">[1, 2, 3]</span></code> <-- output<br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">What’s going on here? So I’ve made a list of aliens called “aliens” and I’ve stored the values in them. What’s this mutableListOf thing? Well, that is how in Kotlin we create a list of aliens. If I wanted to change the number 1 to 4, I could do the following:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">aliens[0] = 4</span></code><br/>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">[4, 2, 3]</span></code> <-- output<br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">Remember how with arrays we could not add new aliens once the array was created? Well, lists let us do that. If I want to add a alien containing 5 to our group of aliens, I can do this:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">aliens.add(5)</span></code><br/>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">[4, 2, 3, 5]</span></code> <-- output<br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">Done! We now have our additional alien stored. But can we have aliens containing the same value? Let’s try adding another alien with the same 5 that we just added:</p>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">aliens.add(5)</span></code><br/>
<p style="text-align: left;"></p>
<code class="markup--code markup--li-code" style="padding: 10px; background-color: #ded7d9;"><span style="font-weight: 400;">[4, 2, 3, 5, 5]</span></code> <-- output<br/>
<p style="text-align: left;"></p>
<p style="text-align: left;">Voila! We can have the same number stored more than once!</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">But how does this magic work that allows us to add more aliens to our list? Remember when we said that an array needs to keep all aliens together so it can find them? Programmers created a way to eliminate the need for storing the aliens together so they can instead be scattered throughout the computer’s memory. This is exactly what a list allows us to do.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">The way this works is with what are called <strong>nodes</strong>. A <strong>node</strong> typically has a value and a pointer to another node. To continue on our alien analogy, instead of a value occupying one alien, we create two attached boxes.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">In the first <strong>box</strong>, we store the value <strong>alien</strong>. But in the second <strong>box</strong>, we <em>point, </em>or <em>link</em>, the location of the <strong>second node box</strong> in the list.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><a href="https://giphy.com/gifs/RcS0LhQcEcDrxrpNYY">via GIPHY</a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">What this allows us to do then is to store any of the aliens anywhere in memory, as long as the pointers to other locations are arranged properly. All we need to remember is that for each value we store, we need two <strong>boxes</strong>, one to store an <strong>alien</strong> element, and one to point to the location of the <strong>node box</strong> containing the next value.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">This means that we can add another alien to our list. The way this works is by finding out where the last value of the list is located. We can do this by following the links of the aliens from the beginning to the end. Once we have the last value, we can simply create two more aliens anywhere in memory, then store the new value in the first, and record its location in the second alien of the last value in our list.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">We can also insert a new value in a list in the middle. We create two new aliens. Then we store the value of the first newly created alien in the second alien of the one that should come before it. Then the second of our two new aliens stores the location of the alien that we want to come after it.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;"><a href="https://giphy.com/gifs/1n3J99P2dWZ0K86hX9">via GIPHY</a></p>
<p style="text-align: left;"></p>
<h2 class="subdescription" style="font-weight: 500; color: #aeb1b7; text-align: left;">Conclusion</h2>
<p style="text-align: left;"></p>
<p style="text-align: left;">I hope you enjoyed the first Kotlin Thursday! Join us next week for more! If you're interested in looking at previous Kotlin Thursdays, head over to our <a href="https://github.com/Kotlin-Thursdays" target="_blank" rel="noopener">Github page</a>.</p>
<p style="text-align: left;"></p>
<p style="text-align: left;">Last but not least, this is a crowd-sourced tutorial. Do you have a topic you'd like to talk about? Reach out to us at kthursdays@gmail.com and we'll provide support for writing your lessons and editing your clips. To get started, take a look at our <a href="https://github.com/Kotlin-Thursdays/KT-Documentation" target="_blank" rel="noopener">documentation</a>.</p>
<p></p>
</div>
</div> KotlinConf 2017 Highlight of the Week - Bootiful Kotlin by Josh Longtag:codetown.com,2018-09-11:2197786:Topic:608742018-09-11T17:58:07.199ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/SlBRce-aBOc?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p>
<p style="text-align: center;"><iframe width="560" height="315" src="https://www.youtube.com/embed/SlBRce-aBOc?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p> Chicago GDG Workshop on Kotlin and TornadoFX - recap!tag:codetown.com,2018-08-23:2197786:Topic:610322018-08-23T17:32:12.436ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<p>Hey friends -</p>
<p></p>
<p>If you'd like to catch up with Chicago GDG on the TornadoFX workshop, here is a live stream as well as a link to the github project/tutorial.</p>
<p></p>
<p><strong>Neighborhood Cat Scheduler: </strong><a href="https://github.com/Kotlin-Thursdays/Neighborhood-Cat-Scheduler" rel="noopener" target="_blank">https://github.com/Kotlin-Thursdays/Neighborhood-Cat-Scheduler…</a></p>
<p></p>
<p></p>
<p>Hey friends -</p>
<p></p>
<p>If you'd like to catch up with Chicago GDG on the TornadoFX workshop, here is a live stream as well as a link to the github project/tutorial.</p>
<p></p>
<p><strong>Neighborhood Cat Scheduler: </strong><a href="https://github.com/Kotlin-Thursdays/Neighborhood-Cat-Scheduler" target="_blank" rel="noopener">https://github.com/Kotlin-Thursdays/Neighborhood-Cat-Scheduler</a></p>
<p></p>
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/ghNWi9i6SFQ?wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
</p>
<p></p>
<p>More to come as soon as I can get my life together :)</p>
<p></p>
<p>Cheers!</p>
<p>Amanda</p> Introductory Projects for Kotlin Tuesdays!!tag:codetown.com,2018-05-18:2197786:Topic:598602018-05-18T04:41:40.548ZAmanda Hinchman-Dominguezhttps://codetown.com/profile/AmandaHinchmanDominguez
<p>Hey guys,</p>
<p></p>
<p>I want to introduce simple workshops for you to follow along with! Next Tuesday I will start with TornadoFX, a framework for JavaFX that leverages Kotlin for a more beautiful interface and more concise code. Over the weeks, I'd like you guys to help decide what we look at next: Android, Javascript, React, JSON parsing, and whatever you might think of.</p>
<p></p>
<p>Next week, we make a scheduler for the Cat Neighborhood Sitter. How fun!…</p>
<p></p>
<p>Hey guys,</p>
<p></p>
<p>I want to introduce simple workshops for you to follow along with! Next Tuesday I will start with TornadoFX, a framework for JavaFX that leverages Kotlin for a more beautiful interface and more concise code. Over the weeks, I'd like you guys to help decide what we look at next: Android, Javascript, React, JSON parsing, and whatever you might think of.</p>
<p></p>
<p>Next week, we make a scheduler for the Cat Neighborhood Sitter. How fun!</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/1799503932?profile=original" target="_self"><img src="http://storage.ning.com/topology/rest/1.0/file/get/1799503932?profile=original" width="588" class="align-full"/></a></p>