A Block in Ruby is equivalent to a Lambda or Anonymous (un-named) Function in other languages. It starts with do, ends with end, and its parameters are defined between |…
Mixed Types In Ruby, you don't have to make all of the elements of an Array be the same type: mixed_array = [1, "two", 3.0, joe] Indices Arrays are 0-indexed,…
begin-rescue-end Instead of a try-catch statement from other languages, Ruby uses begin-rescue-end. The rescue block (aka catch) is executed when an exception is thrown from the begin section: begin compute_median(scores)…
Case Statements Switch statements are formed using the case keyword in Ruby. Consider the following if - elsif - if statement: # statement-1 if item_counts[item_id] === 1 count = 1…