Ideas/hints for longest

One approach: Think about writing two functions in Haskell: samelength s1 s2 and longer s1 s2. Use nothing but pattern matching and recursive calls. Then get rid of pattern matching. Can you write samelength in terms of longer? Then see if you can turn those Haskell functions into Ruby.

Two other approaches involve using String's size method but there's more of a leap required. Even in those, however, having routines like samelength and longer can make your code a little easier to read.

while5a.rb, on slide 69, is an example of solving a problem in an interesting way by using some Ruby features that have no Java analogs. How would you write that in Java? What Ruby operations took the place of what Java operations? How close could you make a Java solution to the Ruby solution?