Why do I get the undefined method `start_with? '??

I get:

undefined method 'start_with?' for "-f":String (NoMethodError) 

In this line:

 if arg.start_with?("-v") 

This worked on a different machine, apparently, so I assume this might be a problem with my Ruby installation. Any ideas?

+4
source share
1 answer

String#start_with? was introduced in Ruby 1.8.7. You are apparently using an earlier version, which (unfortunately) is not uncommon, but the 1.8 series is retiring soon, and you should consider updating.

Can't find a reference to String#start_with? at 1.8.6 docs , but it exists at 1.8.7 docs .

+8
source

Source: https://habr.com/ru/post/1486072/


All Articles