On Dec 9, 2005, at 11:37 AM, Wilson Bilkovich wrote:

> Or, something else to think about.. shamelessly borrowed from this
> mailing list a month or so ago..
> Wrapped in lame 'gets' code to let you play with it at the command
> line.  I presume you'd actually do something cooler with STDIN or a
> filename.
>
> class Array
>   def dups
>      h, d = {}, []; each{|e| h[e] ? (d << h.delete(e)) : (h[e] =  
> e)}; d
>   end
> end

That is far too complicated and impossible to read.  I think we  
should be giving new people examples of how to make code clear and  
expressive.

> numbers = []
> while n = STDIN.gets.chomp

$ echo -n '' | ruby -e 'p STDIN.gets'
nil

>   break if n == ''
>   numbers << n
> end
> puts numbers.dups
>
> I love reopening Array.

I like clear, expressive code: [ruby-talk:169927]

-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com