ruby - Function name followed by assignment operator -
this question has answer here:
what following function definition mean? why there assignment operator in function name?
def func=(param) @param = param end
what following function definition mean?
they called writer method in ruby.
why there assignment operator in function name?
it adds sugar in syntax.
while have method as
def func=(param) @param = param end
you can call normal assignment
ob.func = 12 # same obj.func(12)
Comments
Post a Comment