From: Eric Hodel Date: 2005-12-12T16:05:18+09:00 Subject: Re: new to Ruby - pls help in translating this On Dec 11, 2005, at 7:27 AM, William James wrote: > William James wrote: >> William James wrote: >>> Eric Hodel wrote: >>> >>>> seen = {} >>>> >>>> ARGF.each do |elem| >>>> print elem if seen.include? elem >>>> seen[elem] = true >>>> end >>> >>> seen = {} >>> while s = gets >>> print s if seen.key? s >>> seen[ s ] = nil >>> end >>> >>> Or: >>> >>> seen = Hash.new(0) >>> while s = gets >>> print s if ( seen[s] += 1 ) > 1 >>> end This is starting to get pointlessly obfuscated. >> seen, s = Hash.new(0) >> print s if ( seen[s] += 1 ) > 1 while s = gets Stop. You're making things hard to read for the new people. > seen = Hash.new(0) > print if ( seen[$_] += 1 ) > 1 while gets I can't read that so I don't know how you expect someone new to Ruby to read it. I've never seen 'ruby golf' do anything positive. I find it especially inappropriate to be performing these vile manipulations while trying to show new people idiomatic Ruby like they asked for: > Can somebody tell me how this is to be done in Ruby? Or maybe the > Ruby > way on how to attack this whole thing. Thanks. -- Eric Hodel - drbrain@segment7.net - http://segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com