It should be noted that we could also have ‘split’ the Ruby number into an array, but since we don’t have to in order to keep the same functionality, why bother?
And just like that, we’re back in near-identical territory. While this reversed stringed number or array has a length greater than 0…
In Ruby, a ‘bang’ method can take a regular method, apply an exclamation point, and turn it into a destructive method. So, normal ‘slice’ can take parts of an array or string and make a new object that contains those sliced parts while still keeping the original string or array completely intact. When it becomes ‘slice!’, it does the same thing, but also permanently removes the items from the original string or array. The bang method isn’t available for all methods, but it’s very useful when you want to modify your original objects. In this exercise, we take the number string and, starting at the  index, we grab everything until we get to the  index, but not including that index. This means we’re taking the first three characters of the string and pushing them into the empty ‘digits’ array. These slices are permanent, meaning that every time we loop (while the new_number is greater than 0), we’re removing 3 characters from ‘new_number’ and putting them into the ‘digits’ array. Since we’re doing this 3 characters at a time, we end up with an array with numbers grouped by 3, like this [“654”, “321”]. ‘Slice’ and ‘slice!’ work on strings or arrays. The ‘«’ is just a simpler way of saying ‘append’. We could opt to use the ‘push’ method as well for the same result.
Finally, the home stretch. In Ruby, we take our ‘digits’ array, ‘join’ the different groups of 3 together and separate them by commas. So, [“654”, “321”] becomes “654,321”. Lastly, we ‘reverse’ the string so it’s “123,456”. That’s the end for the Ruby method. Pretty straightforward.
Just so you can see it all together, here are both programs, laid out in full:
My name is Edwin Unger, and I’m a web developer. Sort of.