Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell) (a Java 1.5 version)

by IulianU (Initiate)
on Dec 14, 2006 at 22:39 UTC ( #589924=note: print w/replies, xml ) Need Help??


in reply to Re: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell) (a Java 1.5 version)
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)

Of course the above is broken :) It appends a trailing empty space. There are two ways to fix it: 1) return result.toString().trim(); instead of return result.substring(1); 2) filter out zero-length pieces in the for loop with something like if( pc.length() == 0 )
  • Comment on Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell) (a Java 1.5 version)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://589924]
help
Chatterbox?
[LanX]: talking about politics. ..
[LanX]: yet another reason to miss yapc na this year
[shmem]: missing is an euphemism
[Discipulus]: a piano et¨de can be harmfull, anyway
[shmem]: grandola vila morena *sing*

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2017-04-29 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (534 votes). Check out past polls.