In the last guide I implemented an XML parser that counted all of the lines from Shakespeare's Macbeth play. That implementation worked, however it used an iterative approach, which resulted in a highly coupled method that would only be able to work on another XML file if it had an identical structure and set of tag names. In this guide we're going to refactor the solution to utilize a functional approach.
There are some key differences between procs / lambdas and traditional methods in Ruby, however the differences can many times be subtle. In this exercise we'll examine how variable scope is processed differently between the different options.
In many cases, lambdas are the most effective when they're used in conjunction with methods. A method is limited to taking a single block in Ruby, however by leveraging lambdas you are able to pass in as many blocks as needed.
Building a calculator is a popular interview question and a good approach for learning a programming language. In this guide we're going to build a Prefix Notation calculator in Ruby, which enables users to enter an operator, followed by any set of numbers to calculate.
Building validations in programs is a common requirement. In this exercise we'll examine how to ensure a set of dice are valid by implementing a method that returns false if the dice are outside the range of 1-6.
Rock, paper, scissors may seem like a simple game to build, however it offers a great base case for how to build a rule's engine that can be scaled up for more complex systems. In this guide we'll examine how to build the game so that users can play against the computer.
Ruby has a helpful method for removing duplicates from an array, the uniq method. However, there are times when you simply want to know which elements in an array are duplicates. In this guide we'll add a method to the Array class that returns all duplicates. Additionally, I'll examine two approaches to the solution and discuss the benefits of each option.
After reviewing the Rock, Paper, Scissors game code, I realized that there was a bug with the computer guessing mechanism. In this guide we're going to walk through how to implement caching in order to correct the issue.
When it comes to parsing files that contain URLs, a common practice is to have the ability to group URLs by type. In this guide we walk through how to categorize links based on regular expressions.
This is first in the series of Google coding interview questions. In order to pass this exercise, you will need to know how to find all of the potential combinations for an array, along with selecting the values that match a calculated sum.
This guide walks through how to generate all binary strings that can be formed by replacing each wildcard character with a either a '0' or '1'.
devCamp does not support ancient browsers.
Install a modern version for best experience.