Course Week01 Day02

Most of the day emphasized coding style

  • Atomize methods
    • separating individual functionalities makes for a better understanding of overall functionality
  • Each class does one thing, represents one kind of thing


  • .sample chooses a random element from an array
  • .flatten turns an array with nested arrays into a single non-nested array
  • for loops are bad inRuby because their variables bleed into the context of the loop
  • attr_accessor is great, but it doesn’t map arguments to instance variables
  • "".ljust(140, "abcd") will repeat abcd in a string until it is 140 characters long
  • printf allows python like formatting within strings, think the percentage sign
    • it also leaves the cursor immediately after the print, as opposed to on a new line like puts
  • sort_by! provides a great way to use a block to sort elements in the list
  • ARGV returns an array of command line arguments

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