CSC302 2011S, Class 04: Ruby (3) Overview: * Generating methods * An incomplete example * Lab * Reflection Admin: * Coffee and Donuts! * Assignment 1 was returned last night. * Assignment 2 was distributed this weekend. * Do your best to finish labs on your own before the next class, since we may rely on them in that class. (That's less important for the third lab in a sequence, but very important for the first two labs.) * We're trying a new approach for questions on Chapter 3. You can either post a question on Piazzza or you can respond to a question. Questions should be posted by 9 p.m. Answers should be posted by 10 p.m. * EC for Thursday's talk on summer opportunities in CS. Explain the negatives of Ruby. * W/o access to a real array, it's likely that almost anything you do will not scale well. * W/o careful underlying design, it's hard to distribute stuff. * Etc. What was the point of 2.4? * There are lots of ways to make (or pretend to make) methods. * Two approaches * define_method * Intercept the undefined method message * Intercepting "undefined" does not have to be dangerous. You can always throw your own exception * It may be less efficient * How would you implement method dispatch well in Ruby * Hash table * Trie Tate also claims that we've changed the "syntax" of Ruby * E.g., we might write something like add_accessors field Example: * We might write "define a method along with precondition tests" Reflection: * Why did Tate design the file name the way he did?