From: Marcelo Date: 2008-02-20T10:55:27+09:00 Subject: Re: IP Address to Decimal - is an one-liner possible? On Feb 19, 2008 7:38 PM, Tiago Pinto wrote: > Our challenge (between me and my friend) was getting an one-liner for > this. I think it'd be easy with something like Array#map_with_index or > Array#inject_with_index because we use the indexes, here. You already have the answer. Chain the calls that you have. It can get a bit shorter, though: $ ruby -e 'puts "127.0.0.1".split(".").inject(0){|s,i| s+=i.to_i; s*=256}/256' 2130706433 Marcelo