Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined method for main:Object (NoMethodError) though method is defined

Tags:

ruby

I have defined a script with the following code snippet:

check_params param

def check_params(param)
 # some code
end

When I run this I get

undefined method `check_params' for main:Object (NoMethodError)

like image 265
user3587299 Avatar asked Jul 01 '15 21:07

user3587299


1 Answers

Ruby expects the method to be declared before you call it, try to move your method definition before you call the method like:

def check_params(param)
 # some code
end

check_params param
like image 72
aazeem Avatar answered Oct 21 '22 06:10

aazeem