[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Need examples comparing Ruby to Python
From:       David MacQuigg <dmq () gain ! com>
Date:       2004-02-25 1:24:49
Message-ID: eotn30to8nfpa8qtklf3pb9720734mlu9m () 4ax ! com
[Download RAW message or body]

On Wed, 25 Feb 2004 06:20:55 +0900, Mark Hubbart <discord@mac.com>
wrote:

>
>On Feb 23, 2004, at 6:57 AM, Emmanuel Touzery wrote:
>> the ruby code could be simplified:
>> ...
>
>I'm getting into this a little late, but...
>This takes care of it nicely, and looks pretty good:
>
>file, length, name, title = line.chomp.squeeze.split(" | ")

This squeezes everything, not just the name.  But it is still the best
example I've seen so far of the power of Ruby in processing strings.
We do need the regex /\s*\|\s*/ in case we get some data with no space
on one side or the other of the '|' delimiter.

>And, assuming "songs" is an array:
>songs << Song.new(file, length, name, title)
>
>It's difficult to simplify the ("m:ss" => sec) time conversion (while 
>still having it be readable) so I'll just leave that one alone, thank 
>you. :)
>
>--Mark
>
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic