Course Week01 Day03

Emphasis went on recursion today, where simplicity hides around the corner behind a return, and things can get simpler when you pass around self. The hardest part isn’t what needs to be done, but where to place everything that needs to be done so that it returns as desired.


  • { %w{r g b y o p}.sample }
    • can take a block where it will fill each element with a result from that block
      • can do multiples this way too
    • But remember
      • first =,"") will create an array of 100 elements pointing to the same empty string
      • second ={""} will create an array of 100 individual elements
      • The difference between these two becomes obvious when starting to append to the empty string with << , since, appending to any string in the first array will affect all other strings, while in the second, it will not
  • don’t indent the when statements after a case
    • if you put a block under a when, you won’t need a then or an end !
  • if you try to get a range in an array that doesn’t exist, you get an empty array,  not nil

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s