Loops in Rust

Rust has the standard loops one might expect, such as a while (conditional) style loop, and a for (counting) loop. As with most modern languages, it also has a for each style loop. A Bad Type of Loop… One thing that is unique however, is that it also includes a built in infinite loop, which…

Conditions in Rust

Rust has the normal conditions you’d expect with other languages. Similar to go, Rust doesn’t require parenthesis around the boolean condition, unlike many languages. Rust allows for your standard if – else if – else style of statements. You can see an example below: Changing the value of n, will change the output you get….

Working with Variables in Rust

In Rust, variables behave somewhat differently than in many other programming languages. Here’s a breakdown of how variables work in Rust, focusing on their unique features. Default Mutability Philosophy Rust’s choice to make variables immutable by default ensures that developers think carefully about mutability. It aligns with Rust’s overarching philosophy of safety and prevents unintended…

Your First Rust Program

As per usual, we’ll create a simple “Hello World” style app to create our first program in Rust. While you can download and install a Rust compiler on your machine, for our examples, we will use an online editor: https://www.onlinegdb.com/online_rust_compiler Rust requires a main function, like many other languages (C/C++, Java, etc) however, there are…

Ruby Arrays and Hashes

In Ruby, an array is an ordered collection of objects, which can hold multiple data types, including numbers, strings, other arrays, or even objects. Of the languages we’ve looked at, it is most similar to lists in Python, where you can store dynamic types, and they are dynamically sized. There are a couple of ways…

Repetition with Ruby

The Ruby method each allows you to iterate over a list of items. This is essentially a for-each style of loop and is like JavaScript’s each method. Notice that the iterative value is placed inside of two pipe (|) characters. You don’t have to put everything on one line. In fact, you can’t if you have multiple…

Classes in Ruby

Classes do not have to be in a separate file as you can see from the file below. Let’s look at a class, then break it down. Class Definition As with most languages, you use class to define your class definition, and class names typically start with a capital letter. As with conditions, and other…