1.

Difference Between Argument And Parameter In Ruby On Rails ?

Answer»

A parameter represents a VALUE that the METHOD expects you to pass when you call it.

An argument represents the value you pass to a method parameter when you call the method. The calling code supplies the arguments when it calls the method.

In simple WORDS, PARAMETERS APPEAR in method definitions; arguments appear in method calls.

For example, in below method, variables param1 and param2 are the parameters

def foo_method(param1, param2): ....... end

while calling the method, arg1 and arg2 are the arguments

foo_method(arg1, arg2)

A parameter represents a value that the method expects you to pass when you call it.

An argument represents the value you pass to a method parameter when you call the method. The calling code supplies the arguments when it calls the method.

In simple words, parameters appear in method definitions; arguments appear in method calls.

For example, in below method, variables param1 and param2 are the parameters

while calling the method, arg1 and arg2 are the arguments



Discussion

No Comment Found