Ruby Delete Prefix
Today I was working with a Ruby method that deletes the prefix from a string, turning --code
into code
. While there are several ways to get this done, a handy Ruby feature I discovered today is delete_prefix
:
> "--code".delete_prefix("--")
=> "code"
Intention-revealing and very Ruby.
Tweet