user3587299
user3587299

Reputation: 71

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

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)

Upvotes: 6

Views: 12494

Answers (1)

aazeem
aazeem

Reputation: 864

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

Upvotes: 16

Related Questions