<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joel Bryan Juliano on Medium]]></title>
        <description><![CDATA[Stories by Joel Bryan Juliano on Medium]]></description>
        <link>https://medium.com/@joeljuliano?source=rss-d30fb770202c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5AytFL-l6ycr7ag64YWnJQ.jpeg</url>
            <title>Stories by Joel Bryan Juliano on Medium</title>
            <link>https://medium.com/@joeljuliano?source=rss-d30fb770202c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:14:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joeljuliano/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Ruby to Golang — Learning from Ruby Enumerables]]></title>
            <link>https://medium.com/@joeljuliano/from-ruby-to-golang-learning-from-ruby-enumerables-85e9f6575a5d?source=rss-d30fb770202c------2</link>
            <guid isPermaLink="false">https://medium.com/p/85e9f6575a5d</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[enumerable]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Joel Bryan Juliano]]></dc:creator>
            <pubDate>Tue, 28 May 2019 17:49:25 GMT</pubDate>
            <atom:updated>2019-07-16T10:41:21.960Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>From Ruby to Golang — Learning from Ruby Enumerable Methods</h3><p>If you are a speaker in a conference and you are about to proceed, you might ask, “<em>is everyone’s cellphone turned off?</em>”, and later in the middle of your talk, you ask “<em>anyone wants to take a coffee break?</em>”</p><p>Would it be really cool to ask this on large sets of data and avoid micro-managing every stuff in an array? Ask a condition to all elements in an array in one go? This feature is baked in Ruby, which is called the <em>enumerable methods</em>. The equivalent of asking the first question in Ruby is the all? method, that will check if a certain condition for every element is met. The equivalent of asking the latter is the any?method, which would meet the condition if every element is met.</p><p>What if we need to apply them in Go? what can we can learn from Ruby’s enumerable methods and how to apply them in our Go program? Since Go doesn’t have built-in enumerable methods similar in Ruby, we can learn from those Ruby built-in methods and apply them in Go in similar scenarios we need it.</p><p>In this article, we will be discussing how we can learn and introspect those Ruby enumerable methods we enjoyed and create analog methods that we can use in our Go programs. We will discuss each Ruby’s enumerable methods and make an equivalent Go version. Then we will discuss more on how to use those methods in practical applications.</p><p>Ruby has many helper methods that are baked-in to the language to conveniently process collections of data to the desired result.</p><p>The first Ruby enumerable method we will discuss is the all? method.</p><h3>all?</h3><p>In the first paragraph, we asked “<em>Is everyone’s cellphone turned off?</em>”, and if everyone’s cellphone is off we can proceed with our talk.</p><p>Programmatically in Ruby, we are going to use all?.</p><p>This method returns true if the resulting outcome of the array of conditions is true.</p><p>Here’s the Ruby example, wherein the all? helper is readily available in an array.</p><p>The first condition is we ask if the length of each item in the array is greater than 4, which results to true.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e00364578fbc6a532f548d90f8819fbe/href">https://medium.com/media/e00364578fbc6a532f548d90f8819fbe/href</a></iframe><p>The second condition results to false, because &quot;Apple&quot; does not meet the condition that it must have the length of greater than 5.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/217e0b266a42cbbd9571ac370fa942c8/href">https://medium.com/media/217e0b266a42cbbd9571ac370fa942c8/href</a></iframe><p>Applying this on Go, we would have to loop over the length of each element in the array, then we store it in a <em>boolean</em> array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8cf34ecaf01a1292ab882d020f60d24/href">https://medium.com/media/f8cf34ecaf01a1292ab882d020f60d24/href</a></iframe><p>Next, is check if all item in the array returns true, otherwise break if false.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/483580da0e2789eb381950e67d82d955/href">https://medium.com/media/483580da0e2789eb381950e67d82d955/href</a></iframe><p>And here’s my implementation of all? in an example. We created a is_lengthy(int, []string) that accepts the expected length and the array of strings.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d5fd8780769354da061b6e0ec307562/href">https://medium.com/media/9d5fd8780769354da061b6e0ec307562/href</a></iframe><h3>Read the remaining chapter from the book “From Ruby to Golang: A Ruby Programmer’s Guide to Learning Golang” available at <a href="https://leanpub.com/rb2go">https://leanpub.com/rb2go</a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85e9f6575a5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Ruby to Golang — Package Management]]></title>
            <link>https://medium.com/@joeljuliano/from-ruby-to-golang-package-management-b5ff912628f1?source=rss-d30fb770202c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5ff912628f1</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Joel Bryan Juliano]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 12:29:57 GMT</pubDate>
            <atom:updated>2019-07-16T10:40:35.074Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>If you were to install a package in Ruby, you would use the <strong>Rubygems</strong> utility to install a package. If you were to manage your packages, you would add the package in a Gemfile and then use <strong>Bundler</strong>. If you were to use a module defined methods in Ruby, you would use extend or include inside a class. However, how do you do those things in Go?</p><h3>Ruby module and includes equivalent in Go</h3><p>Go allows you to package your Go functions and distribute it remotely or throughout your programs.¹ It works by assigning the package into a namespace that you can use throughout your Go program. Using <a href="https://golang.org/doc/code.html#ImportPaths">import</a>, we can call the package namespace and access its functions. This is comparable to Ruby’s include. Also, when you do an import, Go will look into the GOPATH² and require the package.</p><p>In the following example, we have imported several packages and then used their namespace to access its functions. We also demonstrated assigning a custom name for a package.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f7547028cf8148c3b05075cbc2fb972/href">https://medium.com/media/2f7547028cf8148c3b05075cbc2fb972/href</a></iframe><p>Noticed that we imported time and greeter and use its name as-is to access the package’s functions in our main function. We also imported climate and assign a name weather.</p><h3>Read the remaining chapter from the book “From Ruby to Golang: A Ruby Programmer’s Guide to Learning Golang” available at <a href="https://leanpub.com/rb2go">https://leanpub.com/rb2go</a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5ff912628f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Ruby to Golang — Navigating your Arrays]]></title>
            <link>https://medium.com/@joeljuliano/from-ruby-to-golang-ruby-each-equivalent-in-go-1a78e371c520?source=rss-d30fb770202c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a78e371c520</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Joel Bryan Juliano]]></dc:creator>
            <pubDate>Thu, 12 Jul 2018 13:26:39 GMT</pubDate>
            <atom:updated>2019-07-16T10:38:49.038Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>In Ruby, there’s an each keyword that is used to iterate a list of items in an <a href="https://medium.com/jexia/from-ruby-to-golang-arrays-and-slices-2c046cb3872d">array</a>, <a href="https://medium.com/jexia/from-ruby-to-golang-hash-and-maps-7afb4af79284">hash</a> or sets.</p><p>In this example, we create an array with 4 items, then using each, we create a block iterating over the fruits array, with a local variable fruit, then we print the value of fruit using puts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b49c78b9303d621d9a883ab5ca848be9/href">https://medium.com/media/b49c78b9303d621d9a883ab5ca848be9/href</a></iframe><p>In Go, the equivalent functionality similar to Ruby’s each is the for loop.</p><p>In this example, we will discuss the different ways to use Golang’s for loop to iterate an array.</p><p>To learn more about Go’s Array and Slices, please read my previous article, “<a href="https://medium.com/jexia/from-ruby-to-golang-arrays-and-slices-2c046cb3872d">From Ruby to Golang — Arrays and Slices</a>”.</p><h3>C-style semantic form</h3><p>Probably the most prominent for loop example, the C style semantic form. This initialises i := 0, then adds a condition that if i is less than the length of fruits, i &lt; len(fruits) the for loop will continually run, the last statement continually iterates one to i then stores the sum to itself, via i++.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d1a9c15c7ff414a41f84861f24955f8/href">https://medium.com/media/7d1a9c15c7ff414a41f84861f24955f8/href</a></iframe><h3>Read the remaining chapter from the book “From Ruby to Golang: A Ruby Programmer’s Guide to Learning Golang” available at <a href="https://leanpub.com/rb2go">https://leanpub.com/rb2go</a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a78e371c520" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Ruby to Golang — Arrays and Slices]]></title>
            <link>https://medium.com/@joeljuliano/from-ruby-to-golang-arrays-and-slices-2c046cb3872d?source=rss-d30fb770202c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c046cb3872d</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Joel Bryan Juliano]]></dc:creator>
            <pubDate>Tue, 03 Jul 2018 17:03:51 GMT</pubDate>
            <atom:updated>2019-07-16T10:35:16.509Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Arrays are cheap and fast storage of finite number of data that you can call sequentially, or by its index. If you need a quick way to store fixed number of data to a variable that you iterate over, then use array. Use it when you have to store data of the same type that you need to process for looping.</p><p>In Computer Science, arrays are an <a href="https://en.wikipedia.org/wiki/Search_data_structure#Asymptotic_amortized_worst-case_analysis">O(n) solution</a>¹, it’s best for looping through multiple sets of data.² Because of it being performant and efficient, array has been a preferred way of storage of data when you need to process <em>sequentially</em>, by <em>batch</em> or by <em>bulk</em>.</p><p>Coming from Ruby, arrays can be created either by initialising a variable to a blank array [] or idiomatically using the array class name Array.new.</p><p>Here is an example of initialising and using an array in Ruby: we first a.) initialised an array to a variable, b.) add &quot;foo&quot; to the first index c.) use the array append operator &lt;&lt; to append &quot;bar&quot; to the array, d.) prints the value of the array based on their array index which always starts with 0.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d82b8ddbd0ef7f2511294d92e2c5bd3/href">https://medium.com/media/0d82b8ddbd0ef7f2511294d92e2c5bd3/href</a></iframe><p>In Go, there are two types of array classifications with different type of initialisations, namely the <em>Fixed Arrays</em> and <em>Slices</em>. Both <em>Fixed Arrays</em> and <em>Slices</em> do the same thing what an array does, they both store amounts of data that can be accessed by index.³ However there are a number of differences between the two that we will discuss further.</p><h3><strong><em>Read the remaining chapter from the book “From Ruby to Golang: A Ruby Programmer’s Guide to Learning Golang” available at </em></strong><a href="https://leanpub.com/rb2go"><strong><em>https://leanpub.com/rb2go</em></strong></a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c046cb3872d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Ruby to Golang — Hash and Maps]]></title>
            <link>https://medium.com/@joeljuliano/from-ruby-to-golang-hash-and-maps-7afb4af79284?source=rss-d30fb770202c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7afb4af79284</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Joel Bryan Juliano]]></dc:creator>
            <pubDate>Wed, 27 Jun 2018 12:18:28 GMT</pubDate>
            <atom:updated>2019-07-16T10:36:48.119Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>If you need to store amounts of data programatically in Go, that you can conveniently retrieve by its name and not by its index, then use a map.</p><p>A map is a storage of records that can be retrieved by using a key which is mapped to a value. It is a good way to organise information that can be retrieved later.¹</p><p>Coming from Ruby, a map‘s equivalent is a hash. Hashes can either be created implicitly using {} or using Hash.new. Here&#39;s how hash is created in Ruby. First, we initialise an empty hash by assigning {} to a variable named basket, then we iterate the contents and print the key name and it’s value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fc12a73240addcbade21ace82b608b3/href">https://medium.com/media/5fc12a73240addcbade21ace82b608b3/href</a></iframe><p>In order for us to replicate this example in Go, we would use Go’s built-in keyword called map and place it into a variable that maps a unique name to a value.</p><p>But before we proceed on creating a map, we would need to understand two ways to initialise and allocate a map. By <em>declaration,</em> being able to initialise and allocate later, and by <em>assignment,</em> a one-liner way to initialise and allocate a map.</p><h3>Read the remaining chapter from the book “From Ruby to Golang: A Ruby Programmer’s Guide to Learning Golang” available at <a href="https://leanpub.com/rb2go">https://leanpub.com/rb2go</a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7afb4af79284" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Ruby to Golang — Setter/Getter methods and Instance variables]]></title>
            <link>https://medium.com/@joeljuliano/from-ruby-to-go-ruby-setter-getter-methods-and-instance-variables-3266202eaa6?source=rss-d30fb770202c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3266202eaa6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Joel Bryan Juliano]]></dc:creator>
            <pubDate>Thu, 14 Jun 2018 16:07:02 GMT</pubDate>
            <atom:updated>2019-07-29T18:16:45.727Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Setter/Getter methods and Instance variables</h3><p>If you need to pass values within your code, you would use an <strong>instance variable </strong>in Ruby, but how do you do it in Go? How do you pass values from within functions?</p><p>The answer is using Go’s built-in struct.<br>In Go, struct provides a way to pass a value from within functions.</p><p>In the following example, a class Dog has been created with an initialiser that accepts a parameter breed and set that parameter to an instance variable @breed which can be accessed from within the class.</p><p>In this case, a public method kind directly returns the value passed to the initialiser.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8de2d543e9cecde19c624131f59a43c9/href">https://medium.com/media/8de2d543e9cecde19c624131f59a43c9/href</a></iframe><p><strong>Read the remaining chapter from the book “From Ruby to Golang: A Ruby Programmer’s Guide to Learning Golang” available at </strong><a href="https://leanpub.com/rb2go"><strong>https://leanpub.com/rb2go</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3266202eaa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>