DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
ben profile image
Ben Halpern

Ruby


def remove_first_and_last(string)
  raise "Invalid" if string.size < 3
  string[1..string.size-2]
end
Collapse
databasesponge profile image
MetaDave 🇪🇺

I think you can get away with string[1..-2] there, Ben.