<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Repiki</title>
    <description>The latest articles on Forem by Repiki (@repiki).</description>
    <link>https://forem.com/repiki</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1427108%2F868f58e4-78bc-4247-ad85-fddea5dcfd7e.png</url>
      <title>Forem: Repiki</title>
      <link>https://forem.com/repiki</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/repiki"/>
    <language>en</language>
    <item>
      <title>Ruby Array Methods That Will Blow Your Mind, Pt. 5: The rejected ones</title>
      <dc:creator>Repiki</dc:creator>
      <pubDate>Tue, 07 May 2024 13:45:59 +0000</pubDate>
      <link>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-5-the-rejected-ones-566f</link>
      <guid>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-5-the-rejected-ones-566f</guid>
      <description>&lt;p&gt;No, this last post wasn't rejected but it is a compilation of some somewhat popular Ruby array methods hence why it comes last. But still they are worthy mentions so enjoy.&lt;/p&gt;

&lt;h2&gt;
  
  
  reject
&lt;/h2&gt;

&lt;p&gt;This might be familiar already as the &lt;code&gt;reject&lt;/code&gt; method is used to remove elements from an Enumerable that do not satisfy a given condition. It returns a new array with the elements that were rejected by the condition in the block. This method does not modify the original array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 3, 4, 5, 6]
even_numbers = numbers.reject { |num| num.odd? }
puts even_numbers

# Output: [2, 4, 6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, the &lt;code&gt;reject&lt;/code&gt; method is used to remove all odd numbers from the array. The condition in the block is &lt;code&gt;num.odd?&lt;/code&gt;, so all numbers that satisfy this condition (i.e., all odd numbers) are rejected, and the method returns a new array with the remaining elements (i.e., the even numbers).&lt;/p&gt;

&lt;h2&gt;
  
  
  grep_v
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;grep_v&lt;/code&gt; method is used to filter elements that do not match a specific pattern, typically a regular expression. It returns an array of elements that do not match the given pattern. This method is essentially the inverse of the &lt;code&gt;grep&lt;/code&gt; method, which returns elements that do match the pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = ["apple", "banana", "cherry", "date"]
non_fruits = array.grep_v(/a/)

# Output: ["cherry"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, &lt;code&gt;grep_v&lt;/code&gt; is used to filter out elements that do not contain the letter 'a'. The returned array, &lt;code&gt;non_fruits&lt;/code&gt;, will therefore only include "cherry".&lt;/p&gt;

&lt;h2&gt;
  
  
  compact
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;compact&lt;/code&gt; method is used to remove nil values from an array. This method returns a new array that contains all the non-nil elements from the original array. The original array remains unchanged.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, nil, 3, nil, 4]
array.compact

#Output: [1, 2, 3, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, the &lt;code&gt;compact&lt;/code&gt; method is called on an array that contains some nil values. The method returns a new array that contains only the non-nil values. The original array remains unchanged.&lt;/p&gt;

&lt;p&gt;This brings our exposé of Ruby array methods to an end. I hope you enjoyed the ride.✌️✌️✌️&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>rails</category>
      <category>ruby</category>
      <category>programming</category>
    </item>
    <item>
      <title>Ruby Array Methods That Will Blow Your Mind, Pt. 4: Fusions</title>
      <dc:creator>Repiki</dc:creator>
      <pubDate>Wed, 01 May 2024 13:02:11 +0000</pubDate>
      <link>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-4-fusions-3g9n</link>
      <guid>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-4-fusions-3g9n</guid>
      <description>&lt;p&gt;This is the second to the last part of this series where we consider some more interesting methods to combine array of arrays into one single array.&lt;/p&gt;

&lt;h2&gt;
  
  
  zip
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;zip&lt;/code&gt; method in Ruby arrays is used to combine corresponding elements from two arrays into an array of arrays.(Whew 🤯 so many arrays in there and yet more to come). It takes one or more arrays as arguments and returns a new array of arrays. Each sub-array contains the elements at the same index from each of the input arrays. If the arrays are of different lengths, &lt;code&gt;nil&lt;/code&gt; values are used to fill in the gaps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array1 = [1, 2, 3]
array2 = ['a', 'b', 'c']
result = array1.zip(array2)

# Output: [[1, 'a'], [2, 'b'], [3, 'c']]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;zip&lt;/code&gt; is called on &lt;code&gt;array1&lt;/code&gt; with &lt;code&gt;array2&lt;/code&gt; as an argument. The method combines the elements of &lt;code&gt;array1&lt;/code&gt; and &lt;code&gt;array2&lt;/code&gt; that have the same index into a new array of arrays.&lt;/p&gt;

&lt;h2&gt;
  
  
  flatten
&lt;/h2&gt;

&lt;p&gt;Well you guessed it, the flatten method used to flatten a nested array. This method transforms the nested array into a one-dimensional array. It's important to note that the 'flatten' method doesn't modify the original array unless it's called as 'flatten!'. Another important bit to note is that flatten doesn't take a block which is one very vital distinguising factor from &lt;code&gt;flat_map&lt;/code&gt; described below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nested_array = [[1, 2, [3, 4]], [5, 6], 7]
flattened_array = nested_array.flatten
puts flattened_array
# Output: [1, 2, 3, 4, 5, 6, 7]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, the 'flatten' method is called on the 'nested_array'. The result is a new array 'flattened_array' where all elements are in a single, un-nested level.&lt;/p&gt;

&lt;h2&gt;
  
  
  flat_map
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;flat_map&lt;/code&gt; method is literally a combination of the normal &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;flatten&lt;/code&gt; methods. It is used to transform each element using a block and then flatten the result into a single array. This method is particularly useful when you want to map over an array, and the block you pass returns an array for each element. The &lt;code&gt;flat_map&lt;/code&gt; method will flatten all of these into a single array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;arrays = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
flat_mapped = arrays.flat_map { |array| array }

# Output: flat_mapped will be [1, 2, 3, 4, 5, 6, 7, 8, 9]
# Just returning the elements behave like the normal `flatten`

arrays = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
flat_mapped = arrays.flat_map { |array| array * 2 }

# Output: flat_mapped will be [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, &lt;code&gt;flat_map&lt;/code&gt; is called on an array of arrays. The block passed to &lt;code&gt;flat_map&lt;/code&gt; simply returns each sub-array as it is in the first example while in the second, it doubles the array then flattens it into a single array.&lt;/p&gt;

&lt;p&gt;If you know other interesting methods don't be shy to drop it in the comments as we prepare to go through the last bit in the series of interesting Ruby Array methods.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>rails</category>
      <category>ruby</category>
      <category>coding</category>
    </item>
    <item>
      <title>Ruby Array Methods That Will Blow Your Mind, Pt. 3: Lord of the Slices</title>
      <dc:creator>Repiki</dc:creator>
      <pubDate>Sun, 21 Apr 2024 15:26:24 +0000</pubDate>
      <link>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-3-lord-of-the-slices-4gm0</link>
      <guid>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-3-lord-of-the-slices-4gm0</guid>
      <description>&lt;p&gt;It's all about slicing in this part and we all know at some stage in your development journey, you will need to split an array in various forms. We went through some already but even some more won't be bad.🫥😉🫥&lt;/p&gt;

&lt;h2&gt;
  
  
  slice
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;slice&lt;/code&gt; method returns a portion of the array based on the provided indices. It does not modify the original collection but instead creates a new one that contains the specified elements. The indices can be provided as a start and length, or as a range.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 3, 4, 5]
array.slice(1, 3) 
# Output: [2, 3, 4]

array.slice(0..2)  
# Output: [1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the first example, the &lt;code&gt;slice&lt;/code&gt; method starts at index 1 and takes 3 elements. In the second example, it takes the elements from index 0 to 2. Note that the original array remains unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  slice_before
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;slice_before&lt;/code&gt; method is used to group consecutive elements based on a given block. It slices the array before a given element, creating an array of arrays based on the specified condition. This method is particularly useful when you want to split or group elements in a collection based on a certain condition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 3, 4, 5, 6]
sliced_array = array.slice_before { |element| element.even? }
sliced_array.to_a 

# Output: [[1], [2, 3], [4, 5], [6]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the &lt;code&gt;slice_before&lt;/code&gt; method slices the array before every even number. As a result, we get an array of arrays, where each sub-array starts with an even number and includes the following odd numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  slice_when
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;slice_when&lt;/code&gt; method is used to slice the array when the block's condition is true. It creates an array of arrays based on the specified condition. This method is particularly useful when you want to group consecutive elements in a collection based on a certain condition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 4, 9, 10, 11, 12, 15, 16, 19, 20]
sliced = numbers.slice_when { |i, j| i+1 != j }
sliced.to_a 

# Output: [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the &lt;code&gt;slice_when&lt;/code&gt; method slices the &lt;code&gt;numbers&lt;/code&gt; array when the condition &lt;code&gt;i+1 != j&lt;/code&gt; is true. This results in groups of consecutive numbers being grouped together in sub-arrays.&lt;/p&gt;

&lt;h2&gt;
  
  
  slice_after
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;slice_after&lt;/code&gt; method is used to slice the array after a given element. It creates an array of arrays based on the specified condition. It slices the collection after a given element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 3, 4, 5, 6]
sliced_array = array.slice_after { |i| i.even? }
sliced_array.to_a 

# Output: [[1, 2], [3, 4], [5, 6]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, the &lt;code&gt;slice_after&lt;/code&gt; method is used to slice the array after every even number. The result is an array of arrays, where each sub-array ends with an even number.&lt;/p&gt;

&lt;p&gt;Don't stop slicing till next time when we highlight the glue methods just incase you overslice😉😉.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ruby</category>
      <category>rails</category>
      <category>programming</category>
    </item>
    <item>
      <title>Ruby Array Methods That Will Blow Your Mind, Pt. 2: Splitters Everywhere</title>
      <dc:creator>Repiki</dc:creator>
      <pubDate>Thu, 18 Apr 2024 21:45:36 +0000</pubDate>
      <link>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-2-splitters-everywhere-1lad</link>
      <guid>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-pt-2-splitters-everywhere-1lad</guid>
      <description>&lt;p&gt;If you haven't seen the first bit please follow this &lt;a href="https://dev.to/repiki/ruby-array-methods-that-will-blow-your-mind-1mjg"&gt;link&lt;/a&gt; so you get the first scoop or you can also carry on with this too and backtrack later.&lt;/p&gt;

&lt;p&gt;Getting down straight to the business of the day, showcasing even cooler ruby methods...&lt;/p&gt;

&lt;h2&gt;
  
  
  partition
&lt;/h2&gt;

&lt;p&gt;I bet you never knew this method existed in ruby😜. Cool yeah!😎. The &lt;code&gt;partition&lt;/code&gt; method is used to divide elements of an array into two groups based on a given condition. It returns an array of two arrays. The first array contains elements for which the block evaluates to true, and the second array contains elements for which the block evaluates to false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 3, 4, 5, 6]
even_and_odd = numbers.partition { |number| number.even? }

# Output: [[2, 4, 6], [1, 3, 5]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the &lt;code&gt;partition&lt;/code&gt; method is used to separate even and odd numbers in the array. The returned array contains two arrays: the first with even numbers and the second with odd numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  each_cons
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;each_cons&lt;/code&gt; method is used to iterate over consecutive elements in the collection. This method allows you to process elements in sliding windows of a specified size. It provides a way to iterate over consecutive elements in the collection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 3, 4, 5]
array.each_cons(2) { |a| p a }

# Output:
# [1, 2]
# [2, 3]
# [3, 4]
# [4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, &lt;code&gt;each_cons(2)&lt;/code&gt; iterates over the array in groups of two consecutive elements at a time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Do not confuse &lt;code&gt;each_cons&lt;/code&gt; with &lt;code&gt;each_slice&lt;/code&gt; in &lt;a href="https://dev.to/repiki/ruby-array-methods-that-will-blow-your-mind-1mjg"&gt;Part 1&lt;/a&gt; as they split the array differently.&lt;/p&gt;

&lt;p&gt;If you have a sequence of numbers &lt;code&gt;[1, 2, 3, 4, 5]&lt;/code&gt;, &lt;code&gt;each_cons(2)&lt;/code&gt; would yield &lt;code&gt;[[1, 2], [2, 3], [3, 4], [4, 5]]&lt;/code&gt;, whereas &lt;code&gt;each_slice(2)&lt;/code&gt; would yield &lt;code&gt;[[1, 2], [3, 4], [5]]&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  chunk
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;chunk&lt;/code&gt; method groups consecutive elements based on a given block. It returns an enumerable that, when iterated over, yields arrays of two elements. The first element is the result of the block for that group of elements, and the second element is an array of those elements. This method is useful when you want to group consecutive elements together based on some shared characteristic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 3, 4, 5, 6]
chunked = numbers.chunk { |number| number.even? }

# Output: [[false, [1, 3, 5]], [true, [2, 4, 6]]]

chunked.each { |even, array| puts "#{even ? 'Even' : 'Odd'}: #{array}" }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;chunk&lt;/code&gt; method is used to group the numbers into chunks of consecutive even and odd numbers. The block &lt;code&gt;{ |number| number.even? }&lt;/code&gt; is used to determine how to group the elements. The output would be "Odd: [1]", "Even: [2]", "Odd: [3]", "Even: [4]", "Odd: [5]", "Even: [6]".&lt;/p&gt;

&lt;h2&gt;
  
  
  chunk_while
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;chunk_while&lt;/code&gt; method is used to group consecutive elements based on a given block until the block condition is false. It creates an array of arrays representing chunks of elements for which the block condition was true consecutively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 4, 9, 10, 11, 12, 15, 16, 19, 20]
array.chunk_while { |i, j| i + 1 == j }.to_a

Output: [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, &lt;code&gt;chunk_while&lt;/code&gt; groups consecutive integers together into sub-arrays. The block &lt;code&gt;i + 1 == j&lt;/code&gt; checks if the current element and the next element are consecutive numbers.&lt;/p&gt;

&lt;p&gt;Play around with these methods and place them nicely in your ruby toolbox and keep some space as there are more to come.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ruby</category>
      <category>rails</category>
      <category>programming</category>
    </item>
    <item>
      <title>Ruby Array Methods That Will Blow Your Mind.</title>
      <dc:creator>Repiki</dc:creator>
      <pubDate>Mon, 15 Apr 2024 22:44:24 +0000</pubDate>
      <link>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-1mjg</link>
      <guid>https://forem.com/repiki/ruby-array-methods-that-will-blow-your-mind-1mjg</guid>
      <description>&lt;p&gt;It could be a sleek method you use in your day job, your side project or your technical interview but these methods used to process an array in ruby will totally leave you in awe. &lt;/p&gt;

&lt;h2&gt;
  
  
  all?
&lt;/h2&gt;

&lt;p&gt;Yes asking a question about all the elements of your array.The &lt;code&gt;all?&lt;/code&gt; method is used in Ruby to check if all elements in an Enumerable meet a certain condition. It returns &lt;code&gt;true&lt;/code&gt; if all elements satisfy the condition, otherwise it returns &lt;code&gt;false&lt;/code&gt;. This method is particularly useful when you need to validate that every element in a collection such as an array or hash meets a specific criteria.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 3, 4, 5]
all_even = numbers.all? { |num| num.even? }
puts all_even
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the &lt;code&gt;all?&lt;/code&gt; method is used to check if all numbers in the array are even. Since not all numbers are even, the output is &lt;code&gt;false&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  each_slice
&lt;/h2&gt;

&lt;p&gt;Not slices of bread now but slices of your array. Really why process just one element of your array one at a time?&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;each_slice&lt;/code&gt; method allows you to iterate over an array in slices of a given size. This means that instead of processing each element individually, you can process them in groups of a specified size.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 3, 4, 5, 6]
array.each_slice(2) { |slice| p slice }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, the &lt;code&gt;each_slice&lt;/code&gt; method is used to iterate over the array in slices of 2. This will output each slice as an array, resulting in the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1, 2]
[3, 4]
[5, 6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  grep
&lt;/h2&gt;

&lt;p&gt;Oh, you thought grep was only a linux utility? No, it is also available for you in ruby. The &lt;code&gt;grep&lt;/code&gt; method is used to filter elements based on a regular expression. It returns an array with elements that match the pattern. This method is not limited to regular expressions, it can also accept a Class, and it will return an array of elements that are instances of that Class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array = [1, 2, 'three', 'four', 5]
filtered_array = array.grep(String)
# filtered_array will be ['three', 'four']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, &lt;code&gt;grep&lt;/code&gt; is used to filter out the elements of the array that are of the String class. The result is a new array that contains only the string elements from the original array.&lt;/p&gt;

&lt;p&gt;Okay maybe you knew those 3 already but that is just a tip of the iceberg. Keep your fingers crossed for the next set coming soon. &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
