On Mon, 24 Sep 2007 04:41:29 +0900, David A. Black wrote:

> Hi --
> 
> On Mon, 24 Sep 2007, Sebastian Hungerecker wrote:
> 
>> Felix Windt wrote:
>>>> From: Sebastian Hungerecker [mailto:sepp2k / googlemail.com]
>>>> Hash[*File.read(filename).scan(/^.*=.*$/).flatten]
>>>
>>> I believe that should be:
>>>
>>> Hash[*File.read(filename).scan(/^(.*)=(.*)$/).flatten]
>>
>> Yes, it should - sorry about that. Usually I test code before posting
>> it.
> 
> I think it's exactly (?) equivalent to:
> 
>   Hash[*File.read(filename).scan(/[^=\n]+/)]
> 
> if you want to save the flattening operation.

No it's not. The difference is when there are multiple equals signs on a 
single line, the first solution will only split on one, while your 
solution will split on all.


-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/