commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee / Purple Technology <>
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.


> 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

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.

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


Alex Chaffee                     
Purple Technology - Code and Consulting
jGuru - Java News and FAQs       
Gamelan - the Original Java site 
Stinky - Art and Angst           

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message