loading...

re: Daily Challenge #1 - String Peeler VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Hi! A bit late to the party, but here's a Groovy one: String peel(String toPeel) { if(!(toPeel?.length() > 2)) { throw new Exce...
 

My approach in groovy...

Not sure if "ignore <2 chars" means "don't consider" or "ignore the trimming"

Don't consider =>

String peel(String toPeel) {
    toPeel[1..-2]
}

Ignore =>

String peel(String toPeel) {
    toPeel?.length() >2 ? toPeel[1..-2] : toPeel
}

I don't like returning null.

Code of Conduct Report abuse