From: Eric Lavigne Date: 2007-11-19T06:08:05+09:00 Subject: Re: [QUIZ] Goedel (#147) On Nov 18, 2007 3:42 PM, steve wrote: > there's an instance var @primes which has the list of already generated > primes, @primes.last would do it > Sounds simple enough, but accessing instance variables seems to be a rather verbose operation. Here is what it should look like (if the Prime class worked the way I originally expected): primes = Prime.new primes.next.doSomething primes.last.doSomethingElse Here was my first attempt using your suggestion, which looks reasonable but doesn't work. primes = Prime.new primes.next.doSomething primes.@primes.last.doSomethingElse Here is what finally worked, but I can't believe the verbosity of the final line. Is there a shorter way? primes = Prime.new primes.next.doSomething primes.instance_variable_get("@primes").last.doSomethingElse -- There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. - C.A.R. Hoare -