I am using the latest Ruby (version 2.4.1)
I see a method there String#delete_prefix, as defined in
https://ruby-doc.org/core-2.4.1/String.html#method-i-delete_prefix
But in irbthis method for some reason does not exist:
2.4.1 :030 > c="_abc_xyz"
=> "_abc_xyz"
2.4.1 :031 > c.delete_prefix("_")
NoMethodError: undefined method `delete_prefix' for "_abc_xyz":String
from (irb):31
from /Users/jonsmith/.rvm/rubies/ruby-2.4.1/bin/irb:11:in `<main>'
2.4.1 :032 >
What's going on here?!
(The above can be achieved with help c.gsub(/^_/, ''), but I wonder why delete_prefixthey delete_suffixdon't exist contrary to the Ruby documentation.)
source
share