T-4 to HW Due

Test First Ruby

  • 05 silly blocks – 12, + 14
      • Benchmark.realtime {#run this code} returns the time in seconds that it took to run some code
      • to say if var1 and no var2 : if var1 && !var2
      • If you have a class with instance methods, and you want to create a class method that uses the instance methods, say for some manipulation of a variable, use the new method with the same name of the instance variable (that is assigned to a class variable later)
      • require_relative can be used to require files relative to the current file’s working directory, parent directories are simply accessed with ../. So if you are working on the file: places/place1/working_file.rb, and want to access places/place2/another_file.rb, just do a require_relative '../place2/another_file.rb'
      • best to use && for conditionals, I tried using it in the 10_timer exercise with what I wanted to be “do this and then this,” but it didn’t work as expected at all
        • Example:
        • sec = 66 && min = 0
          => 0
          puts “min is #{min} and sec is #{sec}”
        • min is 0 and sec is 0
          => nil
      • in  /[^0-9]/i  the little “i” is for case insensitivity, so its useless.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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