DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
webcoderph profile image
Maynard Cabalitan • Edited

Ruby

def trimmer(str)
  str.length  > 2  ? str[1..-2] : 'invalid'
end

Or

class String
  def trimmer
    self.length > 2 ? self[1..-2] : 'invalid'
  end
end
Forem Open with the Forem app