commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee / Purple Technology <g...@stinky.com>
Subject Re: [lang] chop and chomp
Date Wed, 05 Mar 2003 21:36:53 GMT
> > chop removes the final character, no matter what it is, and glomming
> > \r\n as if it were a single character
> 
> This is akin to Ruby's chop and shouldn't be changed I think.

+1


> Bad evolution. My fault. The all-succeeding characters feature is one I've
> been using a lot. Given:
> 
> From: Fred
> 
> I can do:
> 
> String head = StringUtils.chomp(hdr, ": ");
> String name = StringUtils.prechomp(hdr, ": ");

So maybe they should be called "splitBefore" and "splitAfter"?  Or
"divide"?  

But in this usage they're revealed to be

s.substring(0, s.lastIndexOf(sep)) and s.substring(s.lastIndexOf(sep))

so maybe we're just talking

substringBefore(str, sep) and substringAfter(str, sep) 

???


> I use prechomp/chomp tons :) I'm not adverse to a different names though,
> as I said, they've evolved a fair bit and I ought to have renamed them
> before they ended up in Lang.

http://thesaurus.reference.com/search?q=chop

Entry: chop
Synonyms: axe, cleave, clip, cube, dice, divide, fell, fragment, hack,
hackle, hash, hew, lop, mangle, mince, sever, shear, slash, truncate,
whack

:-)

-- 
Alex Chaffee                               mailto:alex@jguru.com
Purple Technology - Code and Consulting    http://www.purpletech.com/
jGuru - Java News and FAQs                 http://www.jguru.com/alex/
Gamelan - the Original Java site           http://www.gamelan.com/
Stinky - Art and Angst                     http://www.stinky.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message