From: Will Drewry Date: 2004-10-06T15:13:31+09:00 Subject: Re: A ruby course On Wed, 6 Oct 2004 10:36:43 +0900, Gavin Sinclair wrote: > On Wednesday, October 6, 2004, 3:24:12 AM, Brian wrote: > > > Hello Group, > > > I need more help. > > > Gavin Sinclair wrote: > >> > >> p51. Good exercise. How about another? > >> > > > Anybody has an idea for an exercise on extending existing classes. So > > far the only thing I have come up with is: > > > \exercise{Fibonacci II}{ > > Extend \codetype{Integer} with a function fib that calculates the > > corresponding fibonacci number.} > > > And my creativity is at an all time low. > > There are plenty of examples at http://extensions.rubyforge.org. I > was thinking of something like String#indent as an exercise, but you > haven't taught regexen at this point, so that's out. But something > else might do. > >>>SNIP<<< A question someone asked earlier on ruby-talk might be an easy, but appropriate extension to go with #indent and others: -- String#pack: class String def pack(arg) self.split(//).pack(arg) end end Good luck! /wad