This article started out as a submission to the unique solutions section of one of the RB120 exercises provided by Launch School, but my response got so long that I decided to write an article. Over the course of three exercises we were asked to create
Deck, and finally
PokerHand classes. After creating the
PokerHand class, the further exploration exercise asked us to think about how we would modify our solution to choose the best hand between two poker hands and to choose the best 5 card hand from a 7 card hand.
With Halloween just a couple of days away, what better time to use a horror (okay, comedy horror) film to help us understand a programming concept? While studying for my upcoming Launch School RB109 assessment, the idea popped into my head to use the movie Gremlins as an analogy for non-mutating and mutating methods.
If you haven’t seen Gremlins, here is the information you need to know before continuing:
Mogwai are cute little creatures; in the movie, the main character Billy (a human) is given one as a gift. His name is Gizmo and he is sweet and adorable!
There are three rules Billy must follow to care for Gizmo:
1. Do not expose him to light (it will kill him!)
2. Do not let him come into contact with water.
3. Do not feed him after midnight. …
This article will attempt to strengthen your understanding of local variable scope, especially when working with nested blocks. Launch School students can refer to the Variable Scope assignment in Lesson 2 of RB101. I have modified the nested blocks code (example 4) from that assignment to fit my story. Here we go!
Imagine an office building, where the CEO works on the top floor, the manager works on the middle floor, and the doorman works on the ground floor.
In this company, everyone knows the CEO’s name. …