so my question is: how can you assign a variable calling a method as a method name? It feels like I'm missing something..
You don't. In this code
def name=(name)
@name = name
end
name=
isn't a variable name
calling a method =
. The name of the method is name=
.
Edit:
In the above code snippet the def
paired with a terminating end
constitutes a method definition.
def method_name(param1, param2)
# method body
end
On the same line as def
there can only be the method name, optional parentheses, and the param list. By definition having a "variable calling a method" in that line would be illegal. So in your code name=
is the method name.