[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how this will look in ruby?

adm

8/26/2008 6:45:00 AM

sorry for asking conversion and not doing it myself(since I've little
to none knowledge of Ruby).
Can somebody translate this code snippent in Ruby?

sub formatfld {
my $f = shift;
join('', map(ucfirst, split('_', $f)));
}

thanks in advance.
1 Answer

Gregory Brown

8/26/2008 6:55:00 AM

0

On Tue, Aug 26, 2008 at 2:45 AM, adm <avinash.magar@gmail.com> wrote:
> sorry for asking conversion and not doing it myself(since I've little
> to none knowledge of Ruby).
> Can somebody translate this code snippent in Ruby?
>
> sub formatfld {
> my $f = shift;
> join('', map(ucfirst, split('_', $f)));
> }

def format(string)
string.split(/_/).map { |e| e.capitalize }.join
end

--
Technical Blaag at: http://blog.majesticseacr... | Non-tech
stuff at: http://metametta.bl...