3.2.0 :002 > File.exists?("xyz")
(irb):2:in `<main>': undefined method `exists?' for File:Class (NoMethodError)
Did you mean? exist?
from /Users/jason/.rvm/rubies/ruby-3.2.0/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
from /Users/jason/.rvm/rubies/ruby-3.2.0/bin/irb:25:in `load'
from /Users/jason/.rvm/rubies/ruby-3.2.0/bin/irb:25:in `<main>'
3.2.0 :002 > File.exists?("xyz") (irb):2:in `<main>’: undefined method `exists?’ for File:Class (NoMethodError) Did you
Share
You forgot the question mark (
?) at the end:In general, methods which answer questions will always end with a question mark.
In this case, the method is asking
Filethedoes 'foo' exist?question. The class will return the answer.